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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;



View solution in original post

2 REPLIES 2
Reeza
Super User

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;



EJHansen71
Calcite | Level 5

Thank you so much! Smiley Happy:smileyplus:

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2005 views
  • 0 likes
  • 2 in conversation