This is a beginner question, as I have been working with SAS only on and off.
I work mostly in the 'work' folder and send to sasuser as needed.
I searched around the help forums after the below bombed and did not find anything.
Is there a way to send to a subfolder?
data sasuser.subfolder.have;
set work.have;
run;
Just make the directory before hand and then define a different libref that points to the new directory.
Let's assume your SASUSER libref is configured to point to the directory ~/sasuser.v94 (typical on Unix installs of Foundation SAS). So first create a new directory, let's call it ~/sasuser.v94/subdir. Then in your SAS program define a libref that points to it. Let's use the libref SUBDIR.
libname subdir "~/sasuser.v94/subdir";
Now you can reference SAS datasets in that directory by using a normal two level name with SUBDIR as the libref and the dataset name as the member name.
data subdir.have;
set have;
run;
Personally I never write anything into SASUSER libref because when you have more than one SAS job running (and who doesn't if they are really using SAS for production work?) then you cannot get write access to it in all of them. So instead just point your libref to some other more meaningful directory.
Examples:
libname proj1 '~/project1';
libname proj2 '~/project2';
Just make the directory before hand and then define a different libref that points to the new directory.
Let's assume your SASUSER libref is configured to point to the directory ~/sasuser.v94 (typical on Unix installs of Foundation SAS). So first create a new directory, let's call it ~/sasuser.v94/subdir. Then in your SAS program define a libref that points to it. Let's use the libref SUBDIR.
libname subdir "~/sasuser.v94/subdir";
Now you can reference SAS datasets in that directory by using a normal two level name with SUBDIR as the libref and the dataset name as the member name.
data subdir.have;
set have;
run;
Personally I never write anything into SASUSER libref because when you have more than one SAS job running (and who doesn't if they are really using SAS for production work?) then you cannot get write access to it in all of them. So instead just point your libref to some other more meaningful directory.
Examples:
libname proj1 '~/project1';
libname proj2 '~/project2';
The elements of a fully-qualified table reference in SAS don't correlate to physical folders in the file system. So, if you have write access to the SASUSER library, it's possible to create a subfolder there, you'd need to assign a different libref instead of using three-level notation. If that's what you want, then you could go about it like this (examples were tested using PC SAS):
1. Identify the physical location of the SASUSER library. The PATHNAME function can do that for you:
%put NOTE: The SASUSER library is located in %qsysfunc(pathname(sasuser));
In the log:
NOTE: The SASUSER library is located in C:\Users\myUserID\Documents\My SAS Files\9.4
 
You can use the DLCREATEDIR option to make SAS create a folder in the file system when assigning a libref, if the folder does not exist:
options dlcreatedir;
LIBNAME SUB "%qsysfunc(pathname(sasuser))\mySubFolder";
options nodlcreatedir;
From the log:
NOTE: Library SUB was created.
NOTE: Libref SUB was successfully assigned as follows:
Engine: V9
Physical Name: C:\Users\myUserID\Documents\My SAS Files\9.4\mySubFolder
Now, data sets written to the SUB library will be stored in the new mySubFolder folder.
data sub.have;
set work.have;
run;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.