BookmarkSubscribeRSS Feed
goliPSU
Calcite | Level 5

This question is Not Answered.(Mark as assumed answered)

   Goli Magoli Newbie

  

I have a SAS program that uses the micro and at the end is generating the following tables that I want to export it to SQL:

NCxC1993

NCxC1994

NCxC1995

NCxC1996

NCxC1997

I can use the following commands to create a table in SQL but I would like to use a loop:

/*proc sql;

    create table sqldb.cxcuse_dense_1993 as

     select * from NCxC1993; 

    create table sqldb.cxcuse_dense_1994 as

     select * from NCxC1994; 

    create table sqldb.cxcuse_dense_1995 as

     select * from NCxC1995; 

    create table sqldb.cxcuse_dense_1996 as

     select * from NCxC1996; 

    create table sqldb.cxcuse_dense_1997 as

     select * from NCxC1997; 

quit;

run;*/

I am using the following loop but for some reason without any error does not create the tables in SQL (but the above command does)

%macro sqlloop(start=,end=);

     %do year = &start %to &end;

     create table sqldb.cxcuse_dense_&year as

     select * from NCxC&year; 

      %end

%mend;

proc sql;

%sqlloop(start=1994,end=1995)

quit;

run;

/*-----------------------------------------------------------------------*/

quit;

run;

is there any thoughts on why the sqlloop does not work.

Thank you

2 REPLIES 2
Linlin
Lapis Lazuli | Level 10

try adding ";" after %end

goliPSU
Calcite | Level 5

wow, Thank you so much

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
  • 876 views
  • 0 likes
  • 2 in conversation