the first question:
how to read the data in the csv file which have variable names in the first row? like below :
the second question:
the 'Hire Date' variable, there is one blank in it , how to read ?
Name,Hire Date,Company,Country,Date of Birth
Gisela S. Santos,8/12/17,Pede Nunc Sed Limited,Micronesia,8/21/1971
Maxwell L. Cooley,9/4/17,A LLP,Somalia,4/30/1975
Thane P. Obrien,10/28/17,Consectetuer Limited,Jamaica,4/23/1988
Minerva C. Conley,1/5/18,Feugiat Tellus Lorem Institute,Fiji,2/18/1975
Kylee R. Finch,10/31/17,Magna Incorporated,Myanmar,5/18/1973
Calista F. Chambers,9/11/17,Facilisis Incorporated,Libya,3/4/1972
Fuller X. Bradford,1/27/18,Morbi Incorporated,Saint Pierre and Miquelon,12/1/1976
how to read the data in the csv file which have variable names in the first row?
FIRSTOBS=2 in the INFILE statement.
there is one blank in it , how to read ?
Look at the TRUNCOVER/MISSOVER options on the INFILE statement.
if the delimiter is properly specified in the middle it will read correctly, if it's at the end you need to ensure it doesn't try to read from a new line so the TRUNCOVER option is required. Your example doesn't show any missing data however so not sure what you're referring to.
Probably worth skimming the documentation to see what other options are available.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm
@tianerhu wrote:
the first question:
how to read the data in the csv file which have variable names in the first row? like below :
the second question:
the 'Hire Date' variable, there is one blank in it , how to read ?
Name,Hire Date,Company,Country,Date of Birth
Gisela S. Santos,8/12/17,Pede Nunc Sed Limited,Micronesia,8/21/1971
Maxwell L. Cooley,9/4/17,A LLP,Somalia,4/30/1975
Thane P. Obrien,10/28/17,Consectetuer Limited,Jamaica,4/23/1988
Minerva C. Conley,1/5/18,Feugiat Tellus Lorem Institute,Fiji,2/18/1975
Kylee R. Finch,10/31/17,Magna Incorporated,Myanmar,5/18/1973
Calista F. Chambers,9/11/17,Facilisis Incorporated,Libya,3/4/1972
Fuller X. Bradford,1/27/18,Morbi Incorporated,Saint Pierre and Miquelon,12/1/1976
You use FIRSTOBS=2 in the INFILE statement to read over the header line.
And you define the names of variables in the code (particularly the INPUT statement), so what is written in the header line is mostly irrelevant.
Thank you for your help.
how to read the data in the csv file which have variable names in the first row?
FIRSTOBS=2 in the INFILE statement.
there is one blank in it , how to read ?
Look at the TRUNCOVER/MISSOVER options on the INFILE statement.
if the delimiter is properly specified in the middle it will read correctly, if it's at the end you need to ensure it doesn't try to read from a new line so the TRUNCOVER option is required. Your example doesn't show any missing data however so not sure what you're referring to.
Probably worth skimming the documentation to see what other options are available.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm
@tianerhu wrote:
the first question:
how to read the data in the csv file which have variable names in the first row? like below :
the second question:
the 'Hire Date' variable, there is one blank in it , how to read ?
Name,Hire Date,Company,Country,Date of Birth
Gisela S. Santos,8/12/17,Pede Nunc Sed Limited,Micronesia,8/21/1971
Maxwell L. Cooley,9/4/17,A LLP,Somalia,4/30/1975
Thane P. Obrien,10/28/17,Consectetuer Limited,Jamaica,4/23/1988
Minerva C. Conley,1/5/18,Feugiat Tellus Lorem Institute,Fiji,2/18/1975
Kylee R. Finch,10/31/17,Magna Incorporated,Myanmar,5/18/1973
Calista F. Chambers,9/11/17,Facilisis Incorporated,Libya,3/4/1972
Fuller X. Bradford,1/27/18,Morbi Incorporated,Saint Pierre and Miquelon,12/1/1976
Thanks a lot.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.