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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.