Hello Everyone,
I have a data of a 3 set of variable a1-a3 b1-b3 c1-c3.
For a1-a3, I want to calculate a ratio of value*2.0/lag(value)
For b1-b3, I want to calculate a ratio of value*1.0/lag(value)
For c1-c3, I want to calculate a ratio of value*0.5/lag(value)
I don't know how to set condition based on variable name.
Any help is very much appreciated.
Thank you,
HHC
data have;
input id a1 a2 a3 b1 b2 b3 c1 c2 c3;
datalines;
1 1 2 3 11 12 13 111 112 113
2 5 6 7 55 56 57 555 556 557
;
Can you please provide your desired output based on the attached sample?
This will ensure that we are interpreting what you are saying correctly.
Hi Scott,
My output should look like:
1 1 2 3 11 12 13 111 112 113
2 5 6 7 55 56 57 555 556 557
3 0.4 0.66
Essentially, there will be another row added to the file, and this row report the ratio.
Thank you,
HHC
Do you have more than 2 rows of data? Is the same ratio to be calculated between each pair of input rows? Would row 4 in output be the 3rd input row and row 5 the ratio of 2nd and 3rd input rows or rows 4 and 5 be input rows 3 and 4 with output row 6 the ratio?
I only have 2 rows data.
HHC
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.
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.