Hi All!
I am a SAS newbie and as such was given a simple request for which I am having a lot of trouble.
Long story short: I want to pass in an absolute directory, ant then copy all *.sas7bdat files to another directory (hardcoded in the program) with obs=0. So only the metadata. Once I have this I can use perl or bash scripting to rsync these files to another server. This is what I have that works. It is for a single file.
libname data '/data/prod/201004_201403_12_3_3'; /* <-- Search for *.sas7bdat */
libname metadata '/apps/ntzload/nzsas'; /* <-- Copy them here with 0 obs */
data metadata.allsumip; /* <-- Name of one of the files in the lib "data"
set data.allsumip(obs=0);
run;
I've tried to scour the internet and 4 SAS books to find simple looping solutions. I can get a listing of files in a directory, I can't seem to instruct sas to copy them to another directory with ZERO obs. I get error after error and instead of beating my head into a wall - I thought I'd grovel for assistance.
Thank you in advance for your help and patience.
Use option obs=0 if all the datasets in a library.
option obs=0;
proc datasets library=test;
copy in=test out=tests;
run;quit;
option obs=max;
For select names only:
proc sql;
create table dsetlist as
select memname into :memlist from sashelp.vtable
where libname = 'TEST';
quit;
option obs=0;
proc datasets library=test;
copy in=test out=tests;
select &memlist.;
run;quit;
option obs=max;
Use option obs=0 if all the datasets in a library.
option obs=0;
proc datasets library=test;
copy in=test out=tests;
run;quit;
option obs=max;
For select names only:
proc sql;
create table dsetlist as
select memname into :memlist from sashelp.vtable
where libname = 'TEST';
quit;
option obs=0;
proc datasets library=test;
copy in=test out=tests;
select &memlist.;
run;quit;
option obs=max;
Thank you so much! :smileyplus:
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.