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:

sas-innovate-2024.png

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.

 

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