data example2;
infile cards delimiter = ' ' dsd;
length Name $30;
input Name$ ID Score;
cards;
Deepanshu Bhalla 22 987
AttaPat 217 564
Xonxiangnam Samnuelnarayan 33 544
;
proc print noobs;
run;
SAS Output
Deepanshu Bhalla 22 987 | . | . |
Even if i use
length Name :$30; (the same partial O/P occur)
You can't directly. What you have here is bad data. The reason it is bad is because the variables contain the "delimiter", which means there is no logical way to identify where a variable starts and where it finishes, hence it is bad data.
This illustrates good data, where the delimiter is distinct:
data example2; infile cards delimiter=',' dsd; length Name $30; input Name$ ID Score; cards; Deepanshu Bhalla,22,987 AttaPat,217,564 Xonxiangnam Samnuelnarayan,33,544 ; run;
Personally I would send the data back with a fail note, and how to correct it. Otherwise you will need to read in the data as text, then write some text parse statements to split it up as you want.
You can't directly. What you have here is bad data. The reason it is bad is because the variables contain the "delimiter", which means there is no logical way to identify where a variable starts and where it finishes, hence it is bad data.
This illustrates good data, where the delimiter is distinct:
data example2; infile cards delimiter=',' dsd; length Name $30; input Name$ ID Score; cards; Deepanshu Bhalla,22,987 AttaPat,217,564 Xonxiangnam Samnuelnarayan,33,544 ; run;
Personally I would send the data back with a fail note, and how to correct it. Otherwise you will need to read in the data as text, then write some text parse statements to split it up as you want.
@Sathish_jammy you can certainly make SAS read your data as is without touching your values but of course data is a bad data regardless.
data example2;
infile cards delimiter = ' ' ;
input @;
length Name $30;
Name=substr(_infile_,1, anydigit(_infile_)-1);
input @(anydigit(_infile_)) ID score;
cards;
Deepanshu Bhalla 22 987
AttaPat 217 564
Xonxiangnam Samnuelnarayan 33 544
;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.