BookmarkSubscribeRSS Feed
Grandhi4
Calcite | Level 5

Hi all,

This is one xl formula can any one give a sas code (in macros)

=SUM(IF(O7>0.5,0.5+0.5*(O7-0.5),O7), IF(P7>0.5, 0.5+0.5*(P7-0.5),P7),IF(Q7>0.5,0.5+0.5*(Q7-0.5),Q7),IF(R7>0.5,0.5+0.5*(R7-0.5),R7),IF(S7>0.5,0.5+0.5*(S7-0.5),S7),IF(T7>0.5,0.5+0.5*(T7-0.5),T7))

Thanks

suresh

1 REPLY 1
Keith
Obsidian | Level 7

I would use an array to do this in SAS, something along the following lines.

%let val=0.5;

data want;

input o7 p7 q7 r7 s7 t7;

array vars{*} o7--t7;

sumvars=0;

do i=1 to dim(vars);

      sumvars+ifn(vars{i}>&val.,&val.+&val.*(vars{i}-&val.),vars{i});

end;

drop i;

cards;

0.5   0.3   0.2   0.6   0.1   2

;

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 352 views
  • 0 likes
  • 2 in conversation