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

Hello I have a ope_locale on a unix directory that I want to use to make it smaller, by selecting dates less than the current year. 

I create a new table ope_locale from the current table. However, I want to output the new table to another directory in unix /dir/run/folders/files/d2d/tabsas/adobe/test/newtables

I have looked everywhere for a code to output sastables having a sas7bdat format into unix but haven't found any. 
Can someone help please?

 

libname wvsoc "/dir/run/folders/files/d2d/tabsas/adobe/test";

data date;
format date_archiv date9.;

annee_archiv = year(date())-1;
date_archiv = mdy(1,1, input(annee_archiv, best.));
call symput('date_archiv', date_archiv);
run;

proc sql;
create table ope_locale as
select * from wvsoc.ope_locale 
where adb_date_creation > dhms(&date_archiv,0,0,0);
quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Every step that creates a SAS dataset creates a file with a .sas7bdat extension (if run on Windows or UNIX, z/OS or VMS are different). A SAS library (on Windows or UNIX) is a directory containing .sas7bdat files (and .sas7bcat - catalogs, .sas7bvew - views, and some more).

 

So all you need to do is define a LIBNAME for the new location and create the dataset there.

You also need to acquaint yourself with the INTNX and INTCK functions, the most important functions for handling dates and times.

libname wvsoc "/dir/run/folders/files/d2d/tabsas/adobe/test";

libname n_wvsoc "/dir/run/folders/files/d2d/tabsas/adobe/test/newtables";

%let annee_archiv = %sysfunc(intnx(dtyear,%sysfunc(datetime(),-1,b));

data n_wvsocope_locale;
set wvsoc.ope_locale;
where adb_date_creation > &date_archiv.;
quit;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

Every step that creates a SAS dataset creates a file with a .sas7bdat extension (if run on Windows or UNIX, z/OS or VMS are different). A SAS library (on Windows or UNIX) is a directory containing .sas7bdat files (and .sas7bcat - catalogs, .sas7bvew - views, and some more).

 

So all you need to do is define a LIBNAME for the new location and create the dataset there.

You also need to acquaint yourself with the INTNX and INTCK functions, the most important functions for handling dates and times.

libname wvsoc "/dir/run/folders/files/d2d/tabsas/adobe/test";

libname n_wvsoc "/dir/run/folders/files/d2d/tabsas/adobe/test/newtables";

%let annee_archiv = %sysfunc(intnx(dtyear,%sysfunc(datetime(),-1,b));

data n_wvsocope_locale;
set wvsoc.ope_locale;
where adb_date_creation > &date_archiv.;
quit;
LinusH
Tourmaline | Level 20

You just create another libname statment that points to another directory, and then refer to that in your create table statement.

Data never sleeps

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 401 views
  • 0 likes
  • 3 in conversation