10-01-2012 02:45 PM
i am having a data set data main; input sal; cards; 100 200 run; data mon_sal; input days; cards; 2 3 run; %macro sas_cal; proc sql; select count(*) into :cou from mon_sal; select sal into s1-s&cou from main; quit; data mon_sal; set mon_sal; do i=1 %to &cou; mo_days=days*s&cou; %end; run; %mend; %sa_cal; I am trying to iterate it as the same calulation i want to do for few datasets i want the sal from one dataset and days from another datasets to create new variable how can i macro tise it output of mon_sal; days mo_days 2 200 3 600
10-01-2012 03:09 PM
This does not look like a problem where you would need to get into the complexity of MACRO programming. Normal programming will do just fine.
It will probably work better if your two source datasets had some type of ID variable to identify the rows so that you can match the SAL to the proper DAYS. Perhaps MONTH?
If you are willing to assume that the tables should match row by row then you can use merge without a BY statement or two independent SET statements to read one row from each source table per loop of the data step.
mo_days = days*sal;