hyg17
hyg17

Reputation: 237

Checking data vectors in SAS

I want to simply check the values read in SAS. In the raw data file

----+---10----+---20
H Let
P Grn Lea Qua Gro
P Ice     Pls Frm
P Rom     Qua Gro
H Sqs
P Ylw     Tas Acr
P Zuc     Pls Frm

I submitted a code

data a;
infile 'FileA.txt';
 retain vege;
 input code $1. @;
  if code='H' then input @3 vege $3.;
  if code='P';
   input @3 variety : $10. @15 Supplier : $11.;
run;
proc print noobs;
run;

I got the observations

Let P Gm  Gro
Let P Ice Frm
Let P Rom Gro
Sqs P Ylw Acr
Sqs P Zuc Frm

I uderstand that the if code=P; is the reason why the code value is P, but I would like to know if there was supposed to be more observations.

According to the text book I am working on, the sixth observations has certain values and it is indicated by _ N _ =6.

I am still learning and not quite sure what it means... may I have some help?

Thank you.

Upvotes: 1

Views: 47

Answers (1)

Richard
Richard

Reputation: 27536

An if without a then is a special form of if not found in other languages. It is known as a subsetting if and program flow only passes through the statement when the evaluation if true.

Data set rows are output tacitly and implicitly when program flow reaches the bottom of the step (unless there is an explicit output elsewhere in the step)

Thus, all the data file lines were read, only five of them met the sub-setting if criteria asserted by if code='P'; and fell through to the end of the step and were implicitly output.

Upvotes: 1

Related Questions