BookmarkSubscribeRSS Feed
lmacdon4
Calcite | Level 5
Hi,

I have some programs with multiple steps/procedures that I want to run with a loop. For example, the simplest one is:

data reg_temp;
set hotelJPQ.TueDBA0L1_daily;
where (Week_Code>=1) AND (Week_Code<=4);
run;
PROC reg data=reg_temp outest=reg_out_temp;
* parms b0 b1;
DEMAND: model demand = price;
run;
PROC EXPORT DATA= work.reg_out_temp
OUTFILE= "C:\Research\working papers\Joint price quant\Tue_SAS.xls"
DBMS=Excel;
SHEET="1";
run;
quit;

I would like to replace the numeric values in:
where (Week_Code>=1) AND (Week_Code<=4);
and
SHEET="1";
with a variable (say 'x') within a loop such as
Do x = 1 to 9;

Have tried various approaches including different macros but have had no success.

Is there an easy way (or even a way) of accomplishing this.

Thanks,
lmacdon4
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You may consider the SAS macro language for this type of repetitive processing, where only a subset of "variable information" changes iteratively.

Scott Barry
SBBWorks, Inc.

Recommended Google advanced search arguments, this topic/post:

macro language basics site:sas.com

macro variables introduction site:sas.com Message was edited by: sbb
lmacdon4
Calcite | Level 5
thanks.

have tried some macros, but still having problems getting the different procs etc to recognize the 'x' variable.
Cynthia_sas
SAS Super FREQ
Hi:
This paper serves as an excellent intro to the SAS Macro Facility:
http://www2.sas.com/proceedings/sugi28/056-28.pdf

cynthia
lmacdon4
Calcite | Level 5
thanks Cynthia, the above file was very helpful. The macro is working correctly now.

Cheers,
Leo

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 649 views
  • 0 likes
  • 3 in conversation