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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 629 views
  • 1 like
  • 2 in conversation