I've created a number of tables labelled rr1 to rr120. I want to extract columns of data from each one, labelled pred1 to pred120 into one new data file.
I decided the most efficient way to do this would be through the proc SQL function.
What I'm struggling with is how to extract the data from the looping. If I insert the create table instruction within the loop it overwrites 120 times, whereas if I leave it out, I get the query results but no table creation.
Any ideas on how this may be rectified?
Thanks a lot.
create tables results as
%do i = 1 %to 120;
select date, pred&i
order by date;
I'm a bit confused by your description of the data... You always want the DATE var and then
Option 1: from set RR1, you only want PRED1?? and from set RR2, you only want PRED2??
Option 2: Or, from set RR1 you want PRED1-PRED120??? and from set RR2 you want PRED1-PRED120???
Do the datasets RR1-RR120 only have Date and one other variable each, or do the datasets RR1-RR120 each have Date and PRED1-PRED120????
For your final dataset, you want:
DATE PRED1-PRED120 in an output file called RESULTS??
So let's take a look at one possible (theoretical) example of "fake" data from 2 of the files...If the data looked like something like this for RR1 and RR2:
Date PRED1 x1 x2 x3
01/01/2010 111 1 2 3
01/02/2010 222 4 5 6