I have variables name like this
Total1, Male 2 Female1,Total2, Male 2 Female2, Total3, Male 3 Female3, Total4, Male 4 Female4..... Total n, Male n, Female n.
Is there any shortcuts to such variable names to list for input statement? Like X1 X2 X3 --> X1- X3
Thank you for your quick resposne to my question. I have more than 100 sets it would be useful
You just did that! Have you tried?
data test; input x1-x3; cards; 1 2 3 ;
Edit: After viewing @Reeza, I realize that I misread your question. Please ignore my response. I didn't delete it just for the sake of record.
Thank you anyway
Thank you for your quick resposne to my question. I have more than 100 sets it would be useful
You will need to know how many sets appear on a line. And even then the programming is somewhat sophisticated:
data want;
infile rawdata dlm=',';
array total {5};
array male {5};
array female {5};
do J=1 to 5;
input total{J} male{J} female{J} @ ;
end;
run;
The variables won't be stored in the same order internally, but you can certainly shorten the program. Good luck.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.