@Rajeev8080 wrote:
The below is an example taken from google. how if _n_ works here. if i remind myself for PDV it should return only 1 entry as per condition _n_=1, how it returns all of below acctinfo values?
The data step have three main part
if _n_=1 then do;
put @1 "proc format;" ;
put @8 "value account";
end;
This part _surronded by DO and END_ will actually run one time, when reading the first observation from acctinfo dataset. Where the condition IF (_n_= 1) is true.
The second part of the code is the one that returns all of the acctinfo values, which run without any condition in each data step iteration.
put @8 acctnum @20 "= '" name "'";
Finally the part that run only when reading the last observation, where the condition IF (eof = true) is valid and that will happen only one time with you datset.
if eof then do;
put @8 ";";
put @1 "run;";
end;
So the code within the first condition if _n_=1 is not the part that returns all the acctinfo values. But it will be valid for one time based on the condition and the two PUT statment will write to the file only one time.
... View more