DATA Step, Macro, Functions and more

calcul in obs

Accepted Solution Solved
Reply
Contributor
Posts: 41
Accepted Solution

calcul in obs

Hi,

 

I try to do something very easy:

I have a global variable c and a SAS table A.

 

This is working:

data WORK.B;
set WORK.A (firstobs= 2 obs= &c.);
run;

This is not...

data WORK.B;
set WORK.A (firstobs= 2 obs= &c.-1);
run;

Isn't it possible to do it without creating another new variable??

 

Thanks for reply


Accepted Solutions
Solution
‎02-10-2017 09:32 AM
Super User
Posts: 6,946

Re: calcul in obs

Use

set WORK.A (firstobs= 2 obs=%eval(&c.-1));

This lets the macro processor do the calculation and hands a simple number over to the dataset option.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎02-10-2017 09:32 AM
Super User
Posts: 6,946

Re: calcul in obs

Use

set WORK.A (firstobs= 2 obs=%eval(&c.-1));

This lets the macro processor do the calculation and hands a simple number over to the dataset option.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 41

Re: calcul in obs

Thanks Kurt, it is indeed working. Have a good day

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 112 views
  • 1 like
  • 2 in conversation