BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kashili
Calcite | Level 5

I need to call a proc with different argument. In my code below, I have to change

1)value of p in each model statement

2)numeric value in the title.

It seems I cant do it in do loop. Should I use macro or is there a better way of reducing this repetitive code.

thank you

kashili

title "arch=1";

proc autoreg data=Ethylene maxit=2000;

model ret = /  nlags=2  noint garch=(p=1);

run;

title "arch=2";

proc autoreg data=Ethylene maxit=2000;

model ret = /  nlags=2    noint garch=(p=2);

run;

title "arch=3";

proc autoreg data=Ethylene maxit=2000;

model ret = /  nlags=2    noint garch=(p=3);

run;

title "arch=4";

proc autoreg data=Ethylene maxit=2000;

model ret = /  nlags=2    noint garch=(p=4);

run;

title "arch=5";

proc autoreg data=Ethylene maxit=2000;

model ret = /  nlags=2    noint garch=(p=5);

run;

title "arch=6";

proc autoreg data=Ethylene maxit=2000;

model ret = /  nlags=2    noint garch=(p=6);

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Sylas
Fluorite | Level 6


Hi,

Below macro will avoid reptitive use of proc but i don't know whether this the better way of reducing.

%macro proc_rep(p=);

%do i=1 %to &p;

title "arch=&i";

proc autoreg data=Ethylene maxit=2000;

model ret = /  nlags=2  noint garch=(p=&i);

run;

%end;

%mend;

%proc_rep(p=6);

Regards

Sylas.J

View solution in original post

2 REPLIES 2
Sylas
Fluorite | Level 6


Hi,

Below macro will avoid reptitive use of proc but i don't know whether this the better way of reducing.

%macro proc_rep(p=);

%do i=1 %to &p;

title "arch=&i";

proc autoreg data=Ethylene maxit=2000;

model ret = /  nlags=2  noint garch=(p=&i);

run;

%end;

%mend;

%proc_rep(p=6);

Regards

Sylas.J

ArtC
Rhodochrosite | Level 12

The AUTOREG procedure supports multiple MODEL statements.  Each can have its own label.  This allows a single read of the data.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 748 views
  • 0 likes
  • 3 in conversation