Hello,
I have a SPSS syntax that ends with the following : WRITE OUTFILE='Q:\MAC2\Student Registration System (SRS)\Spring 2019\AACC_SRS_2019SP.txt' TABLE /CollectionTerm ',' CollectionYear ',' AACCFICE ',' SubCampusCode ',' SSN_NEW ',' IDType ',' DIDTXT ',' SASID ',' CourseSubject ',' CourseNumber ',' SectionNumber ',' CourseSession ',' CourseHours ',' CourseHourTypeFlag ',' EntryLevelMath ',' EntryLevelEnglish ',' CourseOutcome. EXECUTE. This creates a text file with all of the data records. However, I have to manually insert a header row to the beginning of the file each time I run this syntax. I was wondering if there's a way to have SPSS automatically insert the header row to the text file and save the combined file as US-ASCII 7-bit? The following is a copy of the header row that's manually inserted: Collection_Term,Collection_Year,OPEID,Sub_Campus_Code,Identification_Number_SSN,Identification_Number_Type,Local_Campus_Student_Identifier,SASID,Course_Subject,Course_Number,Section_Number,Course_Session,Course_Hours,Course_Hour_Type_Flag,Entry_Level_Credit_Bearing_Math,Entry_Level_Credit_Bearing_English,Course_Outcome Thanks, Karen -- 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 |
Instead of writing an outfile, have you tried exporting to a .csv file
instead of to a text file? Then your headers can be included using FIELDNAMES... SAVE TRANSLATE OUTFILE='Q:\MAC2\Student Registration System (SRS)\Spring 2019\AACC_SRS_2019SP.csv' /TYPE=CSV /ENCODING='UTF8' /MAP /REPLACE /FIELDNAMES /CELLS=VALUES. -- 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 |
In reply to this post by Egyptkm
First write the header by restraining the output to casenum 1, then print the
records. HTH, PR DO IF ($CaseNum EQ 1). WRITE OUTFILE='Q:\MAC2\Student Registration System (SRS)\Spring /'My Header on the first line'. END IF. *write data lines *. WRITE OUTFILE='Q:\MAC2\Student Registration System (SRS)\Spring 2019\AACC_SRS_2019SP.txt' TABLE /CollectionTerm ',' CollectionYear ',' AACCFICE ',' SubCampusCode ',' SSN_NEW ',' IDType ',' DIDTXT ',' SASID ',' CourseSubject ',' CourseNumber ',' SectionNumber ',' CourseSession ',' CourseHours ',' CourseHourTypeFlag ',' EntryLevelMath ',' EntryLevelEnglish ',' CourseOutcome. EXECUTE. Egyptkm wrote > Hello, > > I have a SPSS syntax that ends with the following : > > WRITE OUTFILE='Q:\MAC2\Student Registration System (SRS)\Spring > 2019\AACC_SRS_2019SP.txt' > TABLE > /CollectionTerm ',' CollectionYear ',' AACCFICE ',' SubCampusCode ',' > SSN_NEW ',' IDType ',' DIDTXT ',' SASID ',' CourseSubject ',' CourseNumber > ',' > SectionNumber ',' CourseSession ',' CourseHours ',' CourseHourTypeFlag > ',' > EntryLevelMath ',' EntryLevelEnglish ',' CourseOutcome. > EXECUTE. > > This creates a text file with all of the data records. However, I have to > manually insert a header row to the beginning of the file each time I run > this syntax. I was wondering if there's a way to have SPSS automatically > insert the header row to the text file and save the combined file as > US-ASCII 7-bit? > > The following is a copy of the header row that's manually inserted: > > Collection_Term,Collection_Year,OPEID,Sub_Campus_Code,Identification_Number_SSN,Identification_Number_Type,Local_Campus_Student_Identifier,SASID,Course_Subject,Course_Number,Section_Number,Course_Session,Course_Hours,Course_Hour_Type_Flag,Entry_Level_Credit_Bearing_Math,Entry_Level_Credit_Bearing_English,Course_Outcome > > Thanks, > Karen > > > > -- > 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 -- 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 |
Free forum by Nabble | Edit this page |