BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10

Hi Guys,

GoodMorning

when we use infile statement to create dataset from extranal data 

IF statement works 

 

3 REPLIES 3
BrahmanandaRao
Lapis Lazuli | Level 10
data dsn;
infile "/home/u35263349/sampleinfile.txt" dsd;
Input id name$ sex$ age sal;
where sex='f'; 
run;

data dsn1;
set dsn;
where sex='f';
run;

Anandkvn_0-1677828143489.png

 

Kurt_Bremser
Super User

Maxim 1!

From the documentation of the WHERE Statement:

Selects observations from SAS data sets that meet a particular condition.

 

Emphasis by me.

You do not read from a dataset (no SET, MERGE, MODIFY or UPDATE statement).

When you want to filter during reading from an external file, you must use a subsetting IF.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

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
  • 3 replies
  • 469 views
  • 1 like
  • 2 in conversation