DATA Step, Macro, Functions and more

Reading raw data from a text file

Occasional Contributor
Posts: 12

Reading raw data from a text file

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

Posts: 9,424

Re: Reading raw data from a text file

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.

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation