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
;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.