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

Hello, everyone

I have +-100  tables that every month I need to have them updated. I'm using this:

%macro append (table);

     proc append base=&table. data=&table. (obs=0); run;

%mend;

%append(have1);

%append(have2);

%append(have3);

...

...

..

%append(have99);

Is there a better way to do this? Some code that list all tables from the dictionary tables and make the proc append using a Loop?

Thanks for any help.

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You could do:

%macro append (table);

     proc append base=&table. data=&table. (obs=0); run;

%mend;

data _null_;

     set sashelp.vtable (where=(libname="XYZ"));

     call execute('%append('||strip(memname)||');');

run;

View solution in original post

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, I would assign them a library reference of their own, so you can identify those files and then do:

data _null_;

     set sashelp.vtables (where=(libname="your libname");

     by libname;

     if first.libname then call execute('data '||strip(memname)||'; set '||strip(memname));

     else call execute(" "||strip(memname));

     if last.libname then call execute('; run;');

run;

This will generate a datastep with a set statement and then a list of all the datasets in the given libname.  Note if the datasets are not the same then the final one will have more variables (proc append will stop working unless you specify not to).

Augusto
Obsidian | Level 7

Hi RW9 thanks, but it's not what I need. If you look at my code I'm updating the same table doing proc append with 'Zero" observations. It seems "strange" but is exactle what I need (once in a while we just have to simple update some tables here).

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, what do you mean by update tables?  Do you mean new variables to be added or variable type to be changed?  I can't see that your code is actually doing anything, i.e. if I have a dataset with 10 observations and 10 variables and then I append the same 10 variable dataset without any rows, I still have a dataset with 10 rows and 10 variables, nothing has changed?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

You could do:

%macro append (table);

     proc append base=&table. data=&table. (obs=0); run;

%mend;

data _null_;

     set sashelp.vtable (where=(libname="XYZ"));

     call execute('%append('||strip(memname)||');');

run;

Augusto
Obsidian | Level 7

RW9 I just wanted to update the modate...

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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