BookmarkSubscribeRSS Feed
goliPSU
Calcite | Level 5

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
Rick_SAS
SAS Super FREQ

I think you probably intended to post this in the macro/sql group: https://communities.sas.com/community/support-communities/sas_macro_facility_data_step_and_sas_langu...

goliPSU
Calcite | Level 5

Thank you so much.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 842 views
  • 0 likes
  • 2 in conversation