- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
RW9 I just wanted to update the modate...