BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Toni2
Lapis Lazuli | Level 10

I am trying to start the loop in %do expression to be equal to start_id =227

 

i use the % SYSEVALF(&start_id.) however, does not work

i want the proc hpbin to have in the WHERE statement the i which should take the values from start_id to end_id 

 

%let start_id=227;
%let end_id=290;

%macro IV_continuous(ds=,vars=,bad=);
                                                                                                 
%let yy=%SYSEVALF((&end_id.-&start_id.)+1);

%do i=%SYSEVALF(&start_id.) %to &yy. ;
 
proc hpbin data = &ds. numbin = 10;
		input &vars.;
		where monthid = &i;
		ods output mapping = bin_&i.;
	run;

%end;
%mend;

%IV_continuous(ds=pd_data.upl_test,vars=&varcon,bad=bad);

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Run this:

%let start_id=227;
%let end_id=290;
%let yy=%SYSEVALF((&end_id.-&start_id.)+1);
%put &=yy.;

Then manually insert the values into your %DO, and you'll see it resolves to this:

%do i = 227 %to 64;

which means the loop will never execute.

Either run it from &start_id to %end_id, or from 1 to &yy.

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

Run this:

%let start_id=227;
%let end_id=290;
%let yy=%SYSEVALF((&end_id.-&start_id.)+1);
%put &=yy.;

Then manually insert the values into your %DO, and you'll see it resolves to this:

%do i = 227 %to 64;

which means the loop will never execute.

Either run it from &start_id to %end_id, or from 1 to &yy.

Toni2
Lapis Lazuli | Level 10
great! thanks

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1139 views
  • 1 like
  • 2 in conversation