Hi All,
Please help, I want to perform the same function for 3 different data sets. Is there a way to do this without having to create 3 separate data sets? Can I use a macro?
Eg:
data a;
set sum1;
dd=datepart(day);
month=month(dd);
year=year(dd);
month=month(dd);
if day(dd) le &max_daya. then day_group="&max_daya.";
if class le 97 then group='c' ;
if class gt 97 and class le 99 then group='02b';
if class in (97,98,99) then group='A';
if class ge 100 then group='H';
cost=cost/100;
vatexcl=cost/1.14;
format dd date.;
run;
data b;
set sum2;
dd=datepart(day);
month=month(dd);
year=year(dd);
month=month(dd);
if day(dd) le &max_dayb. then day_group="&max_daya.";
if class le 97 then group='c' ;
if class gt 97 and class le 99 then group='02b';
if class in (97,98,99) then group='A';
if class ge 100 then group='H'';
cost=cost/100;
vatexcl=cost/1.14;
format dd date.;
run;
data c;
set sum3;
dd=datepart(day);
month=month(dd);
year=year(dd);
month=month(dd);
if day(dd) le &max_dayc. then day_group="&max_daya.";
if class le 97 then group='c' ;
if class gt 97 and class le 99 then group='02b';
if class in (97,98,99) then group='A';
if class ge 100 then group='H';
cost=cost/100;
vatexcl=cost/1.14;
format dd date.;
run;
Hi,
Yes you can do that..
%macro Test(output,input);
data &output;
set &input;
dd=datepart(day);
month=month(dd);
year=year(dd);
month=month(dd);
if day(dd) le &max_daya. then day_group="&max_daya.";
if class le 97 then group='c' ;
if class gt 97 and class le 99 then group='02b';
if class in (97,98,99) then group='A';
if class ge 100 then group='H';
cost=cost/100;
vatexcl=cost/1.14;
format dd date.;
run;
%mend test;
%test(a,sum1);
%test(b,Sum2);
%test(c,Sum3);
Thanks,
Shiva
Hi,
Yes you can do that..
%macro Test(output,input);
data &output;
set &input;
dd=datepart(day);
month=month(dd);
year=year(dd);
month=month(dd);
if day(dd) le &max_daya. then day_group="&max_daya.";
if class le 97 then group='c' ;
if class gt 97 and class le 99 then group='02b';
if class in (97,98,99) then group='A';
if class ge 100 then group='H';
cost=cost/100;
vatexcl=cost/1.14;
format dd date.;
run;
%mend test;
%test(a,sum1);
%test(b,Sum2);
%test(c,Sum3);
Thanks,
Shiva
Thank you Shivas
What about....
if day(dd) le &max_daya. then day_group="&max_daya.";
if day(dd) le &max_dayb. then day_group="&max_dayb.";
if day(dd) le &max_dayc. then day_group="&max_dayc.";
Perhaps
if day(dd) le &&max_day&output. then day_group="&&max_day&output.";
Where are those variables?
Hi Shivas
I could really use your help. Please advise on the below.
I want to automate programs by adding them to my crontab to run daily.
Instead of adding in several entries for the different programs to my crontab, how do I create a macro/program that has all the program calls in it(the different program names)
Also before running the program each day I want the macro to check if the previous days data ran successfully and if the log dependancy for today is met before kicking of the jobs.
Eg: Prog02may2012.sas can only run if the Prog01may2012.sas ran successfully. Also the dependancy "extract.log.ok" needs to be met before I run any programs.
Hope this makes sense.
Thanks, appreciate it.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.