Help using Base SAS procedures

Using IF statement following data and set statements

Reply
Occasional Contributor
Posts: 17

Using IF statement following data and set statements

I am trying to analyze a 2-way factorial RCBD using ANOVA. I have set a PROC IMPORT command from an excel file. One of the variables is Gas, of which Methane, Nitrous Oxide and Carbon Dioxide are options. I want to analyze the data by gas. I wanted to look at Methane first, so, folowing after the PROC IMPORT command i inserted:

data Jul14_1;
set import;

if Gas=Methane;
run;

 

This is followed by PROC SORT, PROC PRINT, and PROC ANOVA commands. Although the Log does not show any errors, the prinout does not include any statistical results just the input data. The log gives one comment in blue: "NOTE: Variable Methane is uninitialized." and anotoher in green: "WARNING: Data set WORK.JUL14_1 was not replaced because new file is incomplete."

 

How do i properly use a command for SAS to only analyze the methane data from the imported excel file?

 

Thanks

Super User
Posts: 19,822

Re: Using IF statement following data and set statements

The error is here, SAS is looking for a variable Methane. If you're trying to specify a string, you enclose it in quotation marks.

"NOTE: Variable Methane is uninitialized."

 

if gas='Methane';

You can also implement the filter directly in your proc using a WHERE clause. 

 

where gas='Methane';

 

Also, if you're going to do the same analysis for all gas types use a BY variable instead of filtering and running for each type.

Occasional Contributor
Posts: 17

Re: Using IF statement following data and set statements

Yup, that worked. Thanks.

Ask a Question
Discussion stats
  • 2 replies
  • 238 views
  • 1 like
  • 2 in conversation