10-25-2013 08:22 AM
I would like to create a macro or array to deal with columns called '0'n to '120'n.
I would like to introduce a loop or somenthing, like do i=0 to 120; but I can't manage to adapt it to this kind of expression ' ..number that gives the name to the column... 'n
10-25-2013 09:31 AM
Can you be bit more specific about what you wish to do?
Have tried something which didn't work, please attach any relevant log.
10-25-2013 11:49 AM
I might be inclined to use the nliteral function. Although my example has no basis in reality.:smileysilly:
10-28-2013 06:59 AM
Sorry guys I can't figure out to apply your statement to my real life situation
my real data have a structure like this:
infile cards dlm=',';
input type $ '1'n '2'n '3'n;
in real life I have many more columns so as I said I would like to avoid to repeat all the column name.
let's imagine a simple macro putting a proc freq of variable '1'n to '3'n? how would you adapt your code to this (in real life I would do thing more complex than proc freq, but it's just a workaround to speak of something easy).
10-28-2013 07:27 AM
Can you take a step back?
Why can't you simply name your variables N0, N1, ..., N120
This would make array processing and looping straight forward.
The variables can also just be given labels 0, 1, ..., 120
10-28-2013 08:07 AM
I did say it had no basis in reality. I think you just need to use a "SAS Variable List"
name range '1'n-numeric-'200'n
10-28-2013 11:43 AM
Here is code to input an arbitrary number of columns named with numbers.
I still have no idea why you would want to do this.
infile cards dlm=',' truncover ;
input type $ "&first"n - "&last"n;
put (_all_) (=);
type=a 1=18 2=12 3=100
type=b 1=20 2=23 3=50
type=c 1=22 2=1 3=75