put Xa=Xb=Xc=_check_;

Reply
Contributor
Posts: 68

put Xa=Xb=Xc=_check_;

Hi guys, I noticed a code as follow:

data _null_  work.one / view=one;

set two;

length _Check_ $10;

if Xa=. then _check_=trim(_Check_)||"Xa";

if Xb=. then _check_=trim(_Check_)||"Xb";

if Xc=. then _check_=trim(_Check_)||"Xc";

put Xa=Xb=Xc=_check_;                       I don't know what's the purpose of writing put Xa=Xb=Xc=_check_;     Could anyone explain it to me?  Thank you;

run;

Respected Advisor
Posts: 4,606

Re: put Xa=Xb=Xc=_check_;

The datastep creates a SAS VIEW called ONE (the mention of _NULL_ is useless here.) A SAS view is not a dataset but a set of instructions that generate a dataset. The PUT statement will write the value of variables to the log every time the view is executed. When a variable name is followed with an equal sign, VARIABLE=value is written to the log, otherwise, only value is written. Try running:

data two;

Xa=1; Xb=.; Xc=.; output;

Xa=.; Xb=2; Xc=3; output;

run;

data one / view=one;

set two;

length _Check_ $10;

if Xa=. then _Check_ = trim(_Check_) || "Xa";

if Xb=. then _Check_ = trim(_Check_) || "Xb";

if Xc=. then _Check_ = trim(_Check_) || "Xc";

put Xa= Xb= Xc= _Check_;

run;

proc print data=one noobs; run;

PG

PG
Ask a Question
Discussion stats
  • 1 reply
  • 322 views
  • 0 likes
  • 2 in conversation