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;
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;
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;
You just create another libname statment that points to another directory, and then refer to that in your create table statement.
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.
Ready to level-up your skills? Choose your own adventure.