DATA Step, Macro, Functions and more

put statement doubt

Reply
SAS Employee
Posts: 73

put statement doubt

data _null_;
input a b;
y = max(a,b);
if _n_ eq 1 then put 'NOTE: A B Y';
put 'NOTE- ' (_all_)(Smiley Happy;
cards;
1 2
3 4
;
run;

what above put statement is doing?
it is displaying the data into log, i know that.
but how, explain?
means i am notable to get what is the meaning of this : 'NOTE- ' (_all_)(Smiley Happy

thanks,
pavan. Message was edited by: pavan
SAS Employee
Posts: 160

Re: put statement doubt

The PUT statement enables you to write information that you specify, including text strings and variable values, to the log. Values can be written in column, list, formatted, or named output style.(footnote 1) Used as a screening device, the PUT statement can also be a useful debugging tool. For example, the following statement writes the values of all variables, including the automatic variables _ERROR_ and _N_, that are defined in the current DATA step:

'NOTE- ' is just plain text

_all_ outputs all variables in you data.

(_all_)(Smiley Happy just means - supress variable names in the output. Try change it to (=); Message was edited by: Geniz
SAS Employee
Posts: 73

Re: put statement doubt

but, i am notable to see this simple text in the log: 'NOTE- '
i am seeing direct values only. y?

the output in log is:

NOTE: A B Y
1 2 2
3 4 4


from above,
NOTE: A B Y is coming from 1st put i.e., if _n_ eq 1 then put 'NOTE: A B Y';

then wht abt 'NOTE- ' from 2nd put statement? where it is? Message was edited by: pavan
SAS Employee
Posts: 160

Re: put statement doubt

If you in SAS put error, warning or note in the log, it is treated special - ie. different colors.

"NOTE-" equals "don't write the word Note" - put the output is indended.
If you wrote PAVAN- or NOTE+, it would have no special meaning for SAS.
Ask a Question
Discussion stats
  • 3 replies
  • 112 views
  • 0 likes
  • 2 in conversation