Hi,
I am using the code:
data Data;
infile datalines;
input name $ age;
datalines;
Sid 14
Alice 13
Barbara 13
Carol 13
Aalfred 13
;
run;
data _null_;
set Data;
file 'C:\Documents and Settings\Desktop\Input\test.txt';
put name $15 @5 age 2.;
run;
The output is:
14 S
13 A
13 B
13 C
13 A
I do not understand how - put statement with @ in the above data _null_works?
Please advise
SK
Sorry ballardw, your post wasn't there when I hit submit. Your solution also works.
In a Put statement think of @ as "at", in you example it is writing the value of Age starting "at" column 5, which is overwriting name. You may want to be using "+5 Age" to write age starting at 5 columns past the end of the previous variable.
Thank you. But I am still unsure why name doesnt start from the first column and I would expect that all the all values for name should occupy 1-4 columns and from 5th column the code would read age.
Regards
SK
Sorry ballardw, your post wasn't there when I hit submit. Your solution also works.
The "@" symbol in this context is a column pointer control. You've instructed SAS to write the AGE variable at column 5 -- which just so happens to overlap with the values in the NAME variable.
Try this instead.
data _null_;
set Data;
file ''C:\Documents and Settings\Desktop\Input\test.txt';
put name @20 age 2.;
run;
There is another defect in your program ... the instructions for writing NAME. The instruction $15 says to write it in column 15. If you meant to say it should occupy 15 characters, there should be a dot $15. added to the instructions.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.