I have many datasets with a sequential naming rule (e.g., Post_1,...,Post_3; but in real-life there are hundreds of datasets).
I want to pull out a certain value from all of the datasets and put it in a %PUT with a sequential naming rule for later use in my code. I have created a version below of what I want to do: I create 3 toy datasets just for a working example, I then try to pull out the X value in the same record for the row with the lowest Y value. In the first example I do this for just one dataset to reveal what I desire. Though, in actual application, I want to do this for a whole bunch of datasets (instead of just Post_1, I would have Post_1-Post_100; So then I would have XMinY_1 through XMinY_100 that I can use later on. The second code section is my attempt to do this, but it does not quite work.
So the overview, I have many datasets that I want to pull a value from each dataset (unique to that set) to put in many sequentially numbered %PUT 's?
Please let me know if you need any more information, I guessing it doesn't like the two & in the put line.
data Post_1(keep= x y i);
call streaminit(123);
do i = 1 to 50;
X = rand("Normal",0, 1);
Y = rand("Normal",2, 1);
output;
end;
run;
data Post_2(keep= x y i);
call streaminit(1234);
do i = 1 to 50;
X = rand("Normal",0, 1.1);
Y = rand("Normal",2.1, 1);
output;
end;
run;
data Post_3(keep= x y i);
call streaminit(12345);
do i = 1 to 50;
X = rand("Normal",0, 2.0);
Y = rand("Normal",2.2, 1);
output;
end;
run;
Proc SQL;
select X into :XMinY_1
from Post_1
having Y=min(Y);
quit;
%put &XMinY_1;
Above functions for a single data set, below attempt at doing this over and over for many datasets.
%MACRO Sets(Start, Stop);
%DO ID_set = &START %TO &STOP;
Proc SQL;
select X into :XMin2Y_&id_set
from Post_&id_set
having Y=min(Y);
quit;
%put &XMin2Y_&id_set;
%END;
%MEND Sets;
%Sets(1,3)
... View more