I’m new to SAS and was wondering how to save a modified data set on SAS. On my SAS enterprise, there is a dataset called cars on sashelp. I modified the dataset to print only those cars which are from "Acura".
proc print data = sashelp.cars;
Where Make="Acura";
run;
Now how do I save this modified data set on my WORK library so that I can retrieve it from there and merge it with other data sets and do some more interesting stuff with it. I tried looking for how to do this on Google but wasn’t able to find a solution. Would appreciate some help. Thanks.
>Solution :
For purposes of saving SAS data sets, there are two key elements to the below code:
- a
datastatement which instructs SAS where to write the file and what to name it:data <library>.<table>. In this case, no library is specified so it will be written to the (default)worklibrary. The table will be namedwant. - a
setstatement which tells you to read the cars table in the sashelp library. One can use thewheredata option to subset the initial table.
data want;
set sashelp.cars(where=(make="Acura"));
run;