BookmarkSubscribeRSS Feed
tonychen1811
Calcite | Level 5

So i wanted to create a macro with a loop. Basically what the macro would do is loop through for a certain number of days. The program is made up of a few parts, first a temporary table is created with the data using create table, then i have a code for it to be stored into the DB. I need the macro to loop through it for a X number of days.

%Macro....;

%do i=to to &..

proc sql;

creat table...

proc sql;

create table..

data_Null;

set work...

proc sql no print;

run;

%end

%mend datastorage

This would be the structure of it. However i keep getting the error of

 

ERROR: The following columns were not found in the contributing tables: i.

Can someone explain to me if this is possible and what i am doing wrong?

2 REPLIES 2
Reeza
Super User

What's possible?

Sorry, your question is extremely vague and its hard to comment on it.


But overall, yes its possible, but it might not be the best solution for your problem anyways.


EDIT:

If you're looping through a macro make sure you're using

%do %to %if %else etc to control execution

ballardw
Super User

Your error makes me believe that you are trying to reference the intended macro variable i, which you should reference as &i, in a position in the sql code where a variable from a table is expected.

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
  • 2 replies
  • 740 views
  • 3 likes
  • 3 in conversation