Hi All,
I am using the code:
DATA test;
INPUT X : 2
Y : 1.
A & $11.
Z : 1.;
DATALINES;
1 2 HELLO WORLD 3
4 5 S BEHNOI 6
;
PROC PRINT DATA=Test;
RUN;
This doesnt read the file correctly. I do not want to change the order of my datalines, could you suggest what change I shoukd make in the Input lines so as to read the data correctly.
Kind Regards
Siddharth
I think your question is how can you read the variable length string in the middle of the line that might had embedded blanks and does NOT have two spaces after it to indicate the end of the variable length string.
In general you cannot. So you will have to use some other method to determining where the number at the end of the line starts.
DATA test;
INPUT x y a & $14. ;
j=input(scan(a,-1,' '),2.);
a=substr(a,1,length(a) - length(scan(a,-1,' ')));
put / _infile_ / (_all_) (=);
DATALINES;
1 2 HELLO WORLD 3
4 5 S BEHNOI 6
;
1 2 HELLO WORLD 3
x=1 y=2 a=HELLO WORLD j=3
4 5 S BEHNOI 6
x=4 y=5 a=S BEHNOI j=6
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.