04-06-2013 05:14 AM
I have a situation .. i have a dataset with name File and has 450 observations. a macro needs to be written as below. Here, first parameter is dataset name and second parameter is no of obs to be read from this data set. Now i want to create datasets file file2 file3 file4 file5 having obs 1 to 100 in file1 , 101 to 200 in file2, 201 to 300 in file3 and 301 to 400 in file4 and 401 to 450 (means remaining obs)in file5. Code will decide the no of datasets to be created at run time. Plz help guys in writing such code....
04-06-2013 08:34 AM
And you don't have a clue on how to do this?
The forums primary objective is not distributing job tasks.
I'm pretty sure that you can do it by yourself if you consume available training, documentation and public papers.
04-06-2013 02:46 PM
I am sorry Linus that i am asking these coding parts but actually i am not that much experienced in SAS as you guys are and i tried to write this code but hanving some issues thats why i have come here to seek some help..
04-06-2013 08:25 PM
Normally people only write macros if they need to generalize the solution for a problem and need some re-usable code. That appears not to be the case here.
Macro language can be very powerful but you should only use it if you can't solve a problem without it.
Get better at Base SAS first.
do i=1 to 450;
data want1 want2 want3 want4 want5;
if 1 <= _n_ <= 100 then output want1;
else if 101 <= _n_ <= 200 then output want2;
else if 201 <= _n_ <= 300 then output want3;
else if 301 <= _n_ <= 400 then output want4;
else if 401 <= _n_ <= 500 then output want5;