DATA Step, Macro, Functions and more

How to print the value of _n_ in log?

Reply
Super Contributor
Posts: 426

How to print the value of _n_ in log?

Could you please tell me how to print the value of _n_  in log from the following code? I could not see the value of _n_ after placing the put _all_ statement.

 

if 1<_n_< %eval(&end_title) then do; put option;end;
put _all_;
if _n_=%eval(&end_title) then do; put option;end;	
put _all_;
PROC Star
Posts: 1,561

Re: How to print the value of _n_ in log?

[ Edited ]

This is in data step right?

 

put _ALL_;

will output all values including the value of _N_.

 

 

put _N_=;

will only output the value of _N_.

 

 

 

Super Contributor
Posts: 426

Re: How to print the value of _n_ in log?

I tried with put _n_ as well , but not getting the value of _n_ in log.
Super User
Posts: 17,818

Re: How to print the value of _n_ in log?

Post your full code.
PROC Star
Posts: 1,561

Re: How to print the value of _n_ in log?

1- use putlog instead of put (if this works you are using a file statement somewhere)

2- do you see anything at all in the log (if not you have redirected the log)?

Super User
Posts: 10,497

Re: How to print the value of _n_ in log?

And what is the value of &end_title? Use of %eval in a data step tells me something is being a tad over coded as if &end_title could have a value of 1+3 then the data step will take that just fine.

If the %eval (&end_title) yields a value of 0 or less then it would not put in either case.

Ask a Question
Discussion stats
  • 5 replies
  • 199 views
  • 0 likes
  • 4 in conversation