BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tianerhu
Pyrite | Level 9

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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


 

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

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.

tianerhu
Pyrite | Level 9

Thank you for your help.

Reeza
Super User

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


 

tianerhu
Pyrite | Level 9

Thanks a lot.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 360 views
  • 0 likes
  • 3 in conversation