BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rush_milo
Obsidian | Level 7

Hi there,

 

exclusion.jpg

 

Based on the image attached above, really appreciate if someone can guide me on how to get the exclusion figures in the yellow box. Does it require the usage of array programming?

 

I'm stuck on writing the code for the exclusion calculation.

 

data summ(drop= t1 t2 t3 t4);

set w1;

base = coalesce(t1,t2,t3,t4);

 

/** stuck here for exclusion calculation **/

run;

 

Anyone's help will be greatly appreciated! Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Here are a couple of statements you could add to the DATA step:

 

exclusion = - dif(base);

if _n_ = 1 then exclusion = 0;

 

View solution in original post

4 REPLIES 4
Astounding
PROC Star

Here are a couple of statements you could add to the DATA step:

 

exclusion = - dif(base);

if _n_ = 1 then exclusion = 0;

 

rush_milo
Obsidian | Level 7

Hi Astounding,

 

Thank you for your prompt reply.

 

I have just started using SAS a few months back. Thank you for introducing me to the DIF function. Have never used this before. Can't wait to try this at work tomorrow. 

 

Again, many thanks! 

 

Loko
Barite | Level 11

From the same category there also is lag function. Of course carefulness shall be paid when using this function and reading the documention might a good start:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212547.htm

 

 

data have;
input item t1 t2 t3 t4 ;
datalines;
1 700 . . .
2 . 650 . .
3 . . 630 .
4 . . . 620
;
run;

data want;
set have;

base = coalesce(t1,t2,t3,t4);
base_prec=lag(base);
exclusion=ifn(base_prec,base_prec-base,0);
run;

rush_milo
Obsidian | Level 7

Thank you Loko and noted. Will go through the documentation and explore more on the lag function. Thanks again! 🙂

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1168 views
  • 2 likes
  • 3 in conversation