data work.homework;
infile datalines dsd;
input name $
age
height;
datalines;
John McCloskey 35 71
June Rosesette 10 43
TinekeJones 9 37
;
proc print data = work.homework;
run;
The main thing is you need to fix the data so that it can be parsed.
Either use a delimiter other than space between the values on the lines. Your current code is expecting a comma as the delimiter as that is the default when the DSD option is used.
data homework;
infile datalines dsd;
input name :$30. age height;
datalines;
John McCloskey,35,71
June Rosesette,10,43
TinekeJones,9,37
;
Or insure there are at least two spaces after the name (and no more than one space in a row in the name) so you can use the & modifier.
data homework;
input name &:$30. age height;
datalines;
John McCloskey 35 71
June Rosesette 10 43
TinekeJones 9 37
;
this program above does not work. Please give me a help.
If you have two spaces after the name, and you use the & to read in the names, then everything will work.
https://www.geeksforgeeks.org/sas-how-to-read-character-using-ampersand/
The main thing is you need to fix the data so that it can be parsed.
Either use a delimiter other than space between the values on the lines. Your current code is expecting a comma as the delimiter as that is the default when the DSD option is used.
data homework;
infile datalines dsd;
input name :$30. age height;
datalines;
John McCloskey,35,71
June Rosesette,10,43
TinekeJones,9,37
;
Or insure there are at least two spaces after the name (and no more than one space in a row in the name) so you can use the & modifier.
data homework;
input name &:$30. age height;
datalines;
John McCloskey 35 71
June Rosesette 10 43
TinekeJones 9 37
;
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 25. 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.