BookmarkSubscribeRSS Feed
sanyam13
Fluorite | Level 6

A raw data file is listed below:

 

 

RANCH,1250,2,1,Sheppard Avenue,"$64,000"

 

SPLIT,1190,1,1,Rand Street,"$65,850"

 

CONDO,1400,2,1.5,Market Street,"80,050"

 

TWOSTORY,1810,4,3,Garris Street,"$107,250"

 

RANCH,1500,3,3,Kemble Avenue,"$86,650"

 

SPLIT,1615,4,3,West Drive,"94,450"

 

SPLIT,1305,3,1.5,Graham Avenue,"$73,650"

 

The following SAS program is submitted using the raw data file as input:

 

data work.condo_ranch;

 infile 'file-specification' dsd;

input style $ @;

if style = 'CONDO' or style = 'RANCH';

input sqfeet bedrooms baths street $ price : dollar10.;  run;

 

can you please help me out in this case , why only 3 observations are in output data set , ? in input there are 5 variables so there should be 5 observation

1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
If you look at the data, you'll see that only 3 rows meet your subsetting IF condition. Read about the subsetting IF in the documentation. BEFORE the second INPUT statement, you have this:
if style='CONDO' or style='RANCH';

What did you think this statement was doing? Any data row that meets the criteria in the IF will go forward in the logic to the second INPUT statement. Any data row that does NOT meet the condition does NOT get parsed or get output.

Only the rows that meet the subsetting IF condition get parsed by the second INPUT statement and get OUTPUT by the implied output at the end of the DATA step program.

Cynthia

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1 reply
  • 625 views
  • 0 likes
  • 2 in conversation