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

Hi,

 

I'm trying to do a do loop with proc sql. The following part of the script gives an error message:

 

%let totalobs = 100;

%let totalobs = &totalobs. + 1;

%put totalobs;

 

ERROR: Open code statement recursion detected.

 

Does anyone know what the issue is?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Your code works fine

 

%let totalobs = 100;

%let totalobs = &totalobs. + 1;

%put totalobs=&totalobs;


/*or*/

%let totalobs = 100;

%let totalobs = %eval(&totalobs. + 1);

%put totalobs=&totalobs;

View solution in original post

5 REPLIES 5
novinosrin
Tourmaline | Level 20

Your code works fine

 

%let totalobs = 100;

%let totalobs = &totalobs. + 1;

%put totalobs=&totalobs;


/*or*/

%let totalobs = 100;

%let totalobs = %eval(&totalobs. + 1);

%put totalobs=&totalobs;

parmis
Fluorite | Level 6

I still get the same error

novinosrin
Tourmaline | Level 20

Try to restart SAS and rerun

 

Here is my log:

 

1840 %let totalobs = 100;
1841
1842 %let totalobs = &totalobs. + 1;
1843
1844 %put totalobs=&totalobs;
totalobs=100 + 1
1845
1846
1847 /*or*/
1848
1849 %let totalobs = 100;
1850
1851 %let totalobs = %eval(&totalobs. + 1);
1852
1853 %put totalobs=&totalobs;
totalobs=101

 

parmis
Fluorite | Level 6

It works. Thank you so much

Astounding
PROC Star

You might get that message if you made the mistake of omitting the first semicolon at the end of the first %LET statement.  If that's not the cause, we might need to see the log including the SQL piece.

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!

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