BookmarkSubscribeRSS Feed
adityakumar1507
Calcite | Level 5

My data set looks like this

 

10001_t      10001_C1   10001_C2  10001_C3  10001_C4    10002_t      10002_B1   10001_B2    10001_B3

value1          value2        value3        value4        value5          value6         value7        value8          value9

value10        value11      value12      value12      value14        value15       valu16        value17        value18

value19        value20      value21      value22      value23        value24       valu25        value26        value27

value28        value29      value30      value31      value32        value33       valu34        value35        value36

 

Now, I want to  divide all the values in 10001_C1 with values in 10001_t , similarly all values in column 10001_C2 will be divided by 10001_t ( which is like the total for that 'C' group, here 10001_C1 is considered as C group) . Division will take place till 10001_C4 column after that the denominator will change ( i.e earlier it was value2/value1 , value3/value1, value4/value1, value5,value1). Now everytime the column name had 't' at the end the denominator will change so when 10002_t comes the denominator will be value_6, so the new table will have percent value in 10002_B1 column as value7/value6, the column 10001_B2 will have vlaue8/value6 and 10001_B3 will have value9/value6. 

I know its a bit confusing but it's all I have and would really appreciate if someone can suggest  a way to solve it. I don't mind if we divide in same table or create a new one. Also the data set is quite big so the code has be dynamic. will really appreciate any help I can get.

 

Thanks

 

2 REPLIES 2
novinosrin
Tourmaline | Level 20

Hi, Thank you for your question. May i request you to provide sample data that would help to have something to work with and test please?

If you could please provide the community with a sample input data and a sample of expected output data so that you and the community can test/validate.

 

Thank you

ballardw
Super User

Since your column names by default are not valid SAS variables show us what the variable names in your SAS data set actually are.

 

Pick a couple variables, show us actual values and what the actual desired output for those values looks like. Real actual numeric non-trivial (not all 1 or 2) numbers.

 

 

 

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 565 views
  • 0 likes
  • 3 in conversation