DATA SoilData;
INPUT Year $ Sample $ Treatment $ Salts $ OM $ NH4 $ NO3 $ P $ @@;
compost.compiled;
run;
PROC Print data=SoilData;
run;
I get an error message
So instead of the myFiles library in my example use the compiled library.
What is the data set name?
You would not be using any INPUT if the data set is already created, only the SET statement as in the example posted.
data class;
set sashelp.class;
run;
proc freq data=sashelp.class;
table age sex;
run;
Your first set of code doesn't specify an input location of where to get the data from.
INPUT implies you're trying to read from a text file originally?
If you want to use an existing data set in a data step you would typically use SET libname.datasetname.
Other statements that may be used to bring in data from existing data sets would be MERGE, to combine data record by record from two or more sets, and UPDATE or MODIFY for specific approaches to changing values of variables when the new value are in a separate data set.
The particular error you show is because you used a code construct with a point between elements that SAS cannot recognize what you intended.
How to use a file you have that already exists, SAS7BDAT
*Path to where the files are stored;
libname myFiles '/home/fkhurshed/Demo1/';
*creates a data set called Sample in the work library;
Data sample;
set myFIles.inputData; *assigns it the data set inputData from the myFiles folder;
run;
*use the file directly without creating a temporary copy;
proc freq data=myFiles.inputData;
table Age Sex;
run;
If it's a text file, you first need to import it into SAS then you can use it.
So instead of the myFiles library in my example use the compiled library.
What is the data set name?
You would not be using any INPUT if the data set is already created, only the SET statement as in the example posted.
data class;
set sashelp.class;
run;
proc freq data=sashelp.class;
table age sex;
run;
The only reason that the dataset SOILANAYLSIS created by the data step:
data SoilAnaylsis;
set compost.compiled;
run;
Would not have any variables would be if the input dataset COMPOST.COMPILED did not have any varaibles.
You probably overwrote your dataset in your earlier attempts.
Recreate it by re-running the code you use to create it from the EXCEL in the first place.
Then try your simple data step that makes a copy of it into the new dataset SOILANALYSIS again.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Ready to level-up your skills? Choose your own adventure.