Hi All,
Sometimes when I hold the value of a variabe in SAS, I am unsure where to use the trailing @ as I get an error when reading other variables. I use this as an example:
Suppose I want to read this text tab delimited file:
Andrew Rapayer 45 61
Abbey Murrey 10 9
Tina Amber 10 20
I should hold the value of Andrew Rapayer and then read off the next two values using @. The code I use:
Data test;
infile "C:\SAS\test.txt" dlm = ' ';
input Name & : $15. @
Age : 2.
Height : 2.
;
run;
Since I am using dlm ='' option so each value is seperated by a space so when I read first obs from text file it would treat Andrew & Rapayer as seperate values but I want to input that as Name so I am using & to read this and then hold the value using @ but I get an error when reading the Age:
ERROR 22-232 : Expecting a Name.
Kindly advise what is the missing link.
Kind Regards
SK
From what I understand, using the ampersand special character/modifier won't help you anyway. When using this modifier SAS treats two or more spaces as the end of the string, which you don't have in your sample data.
From what I understand, using the ampersand special character/modifier won't help you anyway. When using this modifier SAS treats two or more spaces as the end of the string, which you don't have in your sample data.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.