Similar to reading-in the dataset from a Windows directory, we can reverse the process and save the dataset into a hard drive folder via library.
Example
LIBNAME SASLib “/folders/myfolders”;
DATA Work_Example;
a = 1;
run;
DATA SASLib.SASCrunch;
set Work_Example;
run;

Supposedly, we want to save this ‘Work_Example’ dataset (2) into the Windows directory ‘/folders/myfolders’ (so that I can later send this file to my friend, John, via email).
Step 1: Create a library that connects directly to ‘/folders/myfolders‘ ( see (1) above ).
Step 2: Create the dataset with the corresponding library reference ( see (3) above ).
In our example, the dataset ‘SASCrunch’ is created with the library reference of ‘SASLib’. As a result, SAS will save this dataset in the SASLib library.
Again, SASLib is directly connected to the ‘/folders/myfolders‘ folder. The ‘SASCrunch’ dataset saved under there is also saved into the corresponding Windows directory!

DONE! You have learned how to save a SAS dataset into a Windows directory!