I have a data set with 100+ variables for each of many people.
I have two variables for the person's name: lastname and firstname. How can I create an output file using the names (i.e., the values of the variables lastname and firstname)? I would like to do a split file by lastname firstname and export the data for each person into a text file that uses the person's name as the file name. Any help will be greatly appreciated. -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
* A construction like this might suffice Instead of names you have a unique value labeled in totalNameNum as filename; Untested. STRING totalName (A100). COMPUTE = totalName = CONCAT(lastname, ", ", firstname) AUTORECODE VARIABLES = totalName /INTO totalNameNum. DEFINE @export (start = !CHAREND('/') / finish = !CMDEND) !DO !i = !start !TO !finish !LET !filename = !CONCAT(!i, "_Name.csv") TEMPORARY. SELECT IF (totalNameNum = !i). SAVE TRANSLATE /OUTFILE = !filename /TYPE = CSV. !DOEND !ENDDEFINE @export start = 1 finish = <max(totalNameNum)>. Mario Giesel Munich, Germany
Am Montag, 29. Juli 2019, 21:21:54 MESZ hat jpw <[hidden email]> Folgendes geschrieben:
I have a data set with 100+ variables for each of many people. I have two variables for the person's name: lastname and firstname. How can I create an output file using the names (i.e., the values of the variables lastname and firstname)? I would like to do a split file by lastname firstname and export the data for each person into a text file that uses the person's name as the file name. Any help will be greatly appreciated. -- ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
This post was updated on .
In reply to this post by jpw
The same question was posted to comp.soft-sys.stat.spss. I posted a reply
there. https://groups.google.com/forum/#!msg/comp.soft-sys.stat.spss/7qrGJq6wyZ8/VbnZnoepBwAJ In case that link becomes broken in future, here is what I posted. 1. Check to see if you have the SPSSINC SPLIT DATASET extension command installed. If it is installed, you should see "Split into Files" as an option in the Data menu. 2. If it is not installed, click Extensions > Extension Hub. Then search on the word SPLIT and follow the instructions to install SPSSINC_SPLIT_DATASET. 3. Then do something like the following: * Data > Split into Files. SPSSINC SPLIT DATASET SPLITVAR=lastname firstname /OUTPUT DIRECTORY= "C:\Temp" DELETECONTENTS=NO /OPTIONS NAMES=VALUES. Change the DIRECTORY setting as needed. Here's an example I just tried using one of the sample datasets that comes with SPSS. * Use car_sales data to illustrate. * Change path on next line if necessary. GET FILE "C:\SPSSdata\car_sales.sav". * Make variable names match wht OP has. RENAME VARIABLES ( manufact model = lastname firstname). * Data > Split into Files. SPSSINC SPLIT DATASET SPLITVAR=lastname firstname /OUTPUT DIRECTORY= "C:\Temp" DELETECONTENTS=NO /OPTIONS NAMES=VALUES. This code generated 157 separate data files in my C:\Temp folder, one for each row in the original dataset (where there was one row for each lastname/firstname combination). Here are the first several file names: Acura_CL.sav Acura_Integra.sav Acura_RL.sav Acura_TL.sav Audi_A4.sav Audi_A6.sav Audi_A8.sav BMW_323i.sav BMW_328i.sav BMW_528i.sav etc. jpw wrote > I have a data set with 100+ variables for each of many people. > > I have two variables for the person's name: lastname and firstname. > > How can I create an output file using the names (i.e., the values of the > variables lastname and firstname)? > > I would like to do a split file by lastname firstname and export the data > for each person into a text file that uses the person's name as the file > name. > > Any help will be greatly appreciated. > > > > > -- > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@.UGA > (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD ----- -- Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
This post was updated on .
I have SPLIT DATASET . Thank you for telling me about it. I do not think it will let me do what i would like to do.
Below you can see the way my program works now. How can I get the output to be in separate files for each person? SORT CASES BY lastname firstname . SPLIT FILE BY lastname firstname . PRINT / " ". PRINT / "===================================================================". PRINT / "Report of Selected Responses from the". PRINT / "Survey Form Document". Print /"Responses for Candidate: " . Print / firstname. Print / lastname. PRINT / "===================================================================". DO IF (Q1.5month EQ "" OR sysmis(q1.5day) OR sysmis(q1.5year) ). / "1.5. Some or all of date of birth left blank". END IF. [More such print statements.] EXECUTE. SPLIT FILE OFF. -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
SPLIT FILE and SPSSINC SPLIT DATASET are not the same thing. You need the
latter. As I showed in my response in comp.soft-sys.stat.spss, you need something like this: * Data > Split into Files. SORT CASES BY lastname firstname. SPSSINC SPLIT DATASET SPLITVAR=lastname firstname /OUTPUT DIRECTORY= "C:\Temp" DELETECONTENTS=NO /OPTIONS NAMES=VALUES. Change the OUTPUT DIRECTORY setting as necessary. jpw wrote > I have SPLIT DATASET . Thank you for telling me about it. I do not think > it will let me do what i would like to do. > > Below you can see the way my program works now. How can I get the output > to be in > separate files for each person? > > > SORT CASES BY lastname firstname . > > SPLIT FILE BY lastname firstname . > > PRINT / " ". > PRINT / > "===================================================================". > PRINT / "Report of Selected Responses from the". > PRINT / "Survey Form Document". > Print /"Responses for Candidate: " . > Print / firstname. > Print / lastname. > PRINT / > "===================================================================". > > DO IF (Q1.5month EQ "" OR sysmis(q1.5day) OR sysmis(q1.5year) ). > / "1.5. Some or all of date of birth left blank". > END IF. > > [More such print statements.] > > EXECUTE. > > SPLIT FILE OFF. > > > > > > -- > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
SPSSINC SPLIT DATASET will make a separate file for each name, but it makes sav files, not text files. These could be converted using another extension command, SPSSINC PROCESS FILES to iterate over the sav files and convert them to another format. I can explain further if you want to go this route. On Mon, Jul 29, 2019 at 7:15 PM Bruce Weaver <[hidden email]> wrote: SPLIT FILE and SPSSINC SPLIT DATASET are not the same thing. You need the |
In reply to this post by spss.giesel@yahoo.de
Great! Da: SPSSX(r) Discussion [mailto:[hidden email]] Per conto di Mario Giesel * A construction like this might suffice Instead of names you have a unique value labeled in totalNameNum as filename; Untested. STRING totalName (A100). COMPUTE = totalName = CONCAT(lastname, ", ", firstname) AUTORECODE VARIABLES = totalName /INTO totalNameNum. DEFINE @export (start = !CHAREND('/') / finish = !CMDEND) !DO !i = !start !TO !finish !LET !filename = !CONCAT(!i, "_Name.csv") TEMPORARY. SELECT IF (totalNameNum = !i). SAVE TRANSLATE /OUTFILE = !filename /TYPE = CSV. !DOEND !ENDDEFINE @export start = 1 finish = <max(totalNameNum)>. Mario Giesel Munich, Germany Am Montag, 29. Juli 2019, 21:21:54 MESZ hat jpw <[hidden email]> Folgendes geschrieben: I have a data set with 100+ variables for each of many people. I have two variables for the person's name: lastname and firstname. How can I create an output file using the names (i.e., the values of the variables lastname and firstname)? I would like to do a split file by lastname firstname and export the data for each person into a text file that uses the person's name as the file name. Any help will be greatly appreciated. -- ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
In reply to this post by jpw
After looking at the post below again, and reading some of the other
responses, I (think) I now understand that jpw wants (selected bits of) the reports generated by all those PRINT commands to be sent to multiple text files. Here is an example of 3 such reports from the final part of the output, with notations added to indicate where the desired text files begin and end: *** Start of text file Acura_CL.txt *** ================================================================= Report of Selected Responses from the Survey Form Document Responses for Candidate: CL Acura ================================================================= 1.5. Some or all of date of birth left blank *** End of text file Acura_CL.txt *** *** Start of text file Acura_Integra.txt *** ================================================================= Report of Selected Responses from the Survey Form Document Responses for Candidate: Integra Acura ================================================================= 1.5. Some or all of date of birth left blank *** End of text file Acura_Integra.txt *** *** Start of text file Acura_RL.txt *** ================================================================= Report of Selected Responses from the Survey Form Document Responses for Candidate: RL Acura ================================================================= 1.5. Some or all of date of birth left blank *** End of text file Acura_RL.txt *** SPLIT FILE OFF. jpw wrote > I have SPLIT DATASET . Thank you for telling me about it. I do not think > it will let me do what i would like to do. > > Below you can see the way my program works now. How can I get the output > to be in > separate files for each person? > > > SORT CASES BY lastname firstname . > > SPLIT FILE BY lastname firstname . > > PRINT / " ". > PRINT / > "===================================================================". > PRINT / "Report of Selected Responses from the". > PRINT / "Survey Form Document". > Print /"Responses for Candidate: " . > Print / firstname. > Print / lastname. > PRINT / > "===================================================================". > > DO IF (Q1.5month EQ "" OR sysmis(q1.5day) OR sysmis(q1.5year) ). > / "1.5. Some or all of date of birth left blank". > END IF. > > [More such print statements.] > > EXECUTE. > > SPLIT FILE OFF. > > > > > > -- > Sent from: http://spssx-discussion.1045642.n5.nabble.com/ > > ===================== > To manage your subscription to SPSSX-L, send a message to > [hidden email] (not to SPSSX-L), with no body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send the command > INFO REFCARD ----- -- Bruce Weaver [hidden email] http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Free forum by Nabble | Edit this page |