You have this problem because you are violating an old programming truism: information belongs in variable values, not in variable names.
The eliminate this, transpose the data set (proc transpose with the name option will do this easily) so your new structure has two fields, like this:
Day Value
1 1234
2 5678
3 whatever
Your problem has just gone away. You can find the day(s) you want with a subsetting if or a where statement or data set option. The where can be used in a proc step as well, saving preproceesing.
Cheers,
Jonathan
> hello,
> i have the following problem: For each observation in
> my dataset i have hundreds of columns. They are
> named: day_1 day_2 day_3 day_4 day_5.....
> Then I have a variable that contains a number, let's
> say n=4.
>
> Now I want to create another variable, let's say
> 'result', that is equal to day_n.
>
> In my example it should be: result = day_4
> But n is not always 4. So I need a small programme
> that helps me to solve that problem.
>
> Thanks in advance for your help.
> matt