BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
anthonysimerlin
Calcite | Level 5

DATA SoilData;
INPUT Year $ Sample $ Treatment $ Salts $ OM $ NH4 $ NO3 $ P $ @@;
compost.compiled;
run;

PROC Print data=SoilData;
run;

I get an error message 

ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase.
ERROR 557-185: Variable compost is not an object.
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

12 REPLIES 12
Reeza
Super User

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?

 

 

anthonysimerlin
Calcite | Level 5
It is an excel file. I have read and watched videos online on how to import data into sas which i can do. The problem i have is what do you do once it is saved in sas. How do you access it to run code on it. Instead of hand typing the data i should be able to reference it. But when i do i get this error code.
ballardw
Super User

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.

anthonysimerlin
Calcite | Level 5
I already have the file stored in my library and saved to folder compost named compiled. When i open it it gives me my table. I need to be able to insert my table into my program so i can run code on it. So instead of hand typing the hundreds of lines what is the notation for adding the file i have saved in my library?
Reeza
Super User

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.

anthonysimerlin
Calcite | Level 5
I am using an excel file i have imported into sas and then saved to my library. I am trying to have the table it generates show up in sas so i can run analytics on it. does that make sense?
Reeza
Super User

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;
anthonysimerlin
Calcite | Level 5
When i run this line
data SoilAnaylsis;
set compost.compiled;
run;
it then gives me the error
The table "WORK.SOILANAYLSIS" cannot be opened because it does not contain any columns.

which is why i input the column names
Tom
Super User Tom
Super User

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.

anthonysimerlin
Calcite | Level 5
exactly. Thank you for your help.
anthonysimerlin
Calcite | Level 5
for some reason my table didnt have columns. So i reimported the table and now it is working.
anthonysimerlin
Calcite | Level 5
thank you for your help!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 12 replies
  • 998 views
  • 1 like
  • 4 in conversation