08-14-2013 04:21 PM
I am using the code:
input name $ age;
file 'C:\Documents and Settings\Desktop\Input\test.txt';
put name $15 @5 age 2.;
The output is:
I do not understand how - put statement with @ in the above data _null_works?
08-14-2013 04:25 PM
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.
08-14-2013 04:32 PM
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.
08-14-2013 04:35 PM
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.
file ''C:\Documents and Settings\Desktop\Input\test.txt';
put name @20 age 2.;
08-14-2013 05:15 PM
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.
Need further help from the community? Please ask a new question.