Solved
New Contributor
Posts: 3

# Variables listing

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

Accepted Solutions
Solution
‎12-08-2015 12:48 PM
New Contributor
Posts: 3

## Re: Variables listing

[ Edited ]

Thank you for your quick resposne to my question. I have more than 100 sets it would be useful

All Replies
Posts: 3,167

## Re: Variables listing

[ Edited ]

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.

New Contributor
Posts: 3

Thank you anyway

Super User
Posts: 23,778

## Re: Variables listing

Unfortunately not

You could create a macro to create the names, but if you only have 3 it's not useful.

data _null_;
length var \$1000.;

do i=1 to 10;

var=catt(var, " Total"||put(i, 2. -l), " Male"||put(i, 2. -l), " Female"||put(i, 2. -l));
end;

call symputx('input_list', var);
run;

%put &input_list;

Solution
‎12-08-2015 12:48 PM
New Contributor
Posts: 3

## Re: Variables listing

[ Edited ]

Thank you for your quick resposne to my question. I have more than 100 sets it would be useful

Super User
Posts: 6,785

## Re: Variables listing

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.

🔒 This topic is solved and locked.