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

Hi All,

The below table display ranking given by emp for different physical fitness test(like Exercise, Diet, Running etc.). with rank=1 as very low and 5 as very high.
I need to assign category and sub-category for the below table based on below condition.

e.g. "Fitness1" category will be assigned for variable Exercise, Diet, Running  having two sub-categories Fit1, Fit2 for above variable.

Variable  Category    subcategory
Exercise  Fitness1       Fit1
Diet         Fitness1        Fit1
Running  Fitness1        Fit2
jogging    Fitness2         Fit1
playing     Fitness2        Fit4
swimming Fitness3        Fit1
riding         Fitness3        Fit1
dancing      Fitness3        Fit1
sleeping      Fitness3       Fit5

 

After that, I need to calculate the % of rank for each emp based on cat and subcat. 

Kindly help me . The data are confusing

 

data employee;
input eid ename Exercise $ Diet $ Running $ jogging $ playing $ swimming $ riding $ dancing $ sleeping $;
cards;
102 Harish 3 1 1 1 1 3 1 5 1
104 Manu 1 2 1 5 1 3 3 1 2
102 Harish 3 1 2 1 1 3 1 1 1
103 Ram 1 2 2 5 1 3 3 1 1
103 Ram 2 1 1 1 1 3 1 4 1
101 Rakesh 1 2 1 1 1 1 1 1 5
101 Rakesh 1 1 1 4 1 1 1 1 1
106 Gopal 5 1 1 1 1 1 1 3 1
101 Rakesh 1 1 1 1 1 4 1 1 1
;
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

Like the others, I also have no idea of the relationship between the table you present and the data you show.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

5 REPLIES 5
AMSAS
SAS Super FREQ
Sorry, it is not clear to me what you are trying to do.
I assume the above employee dataset is what you have, and you want to add category/subcategory to that. I just don't understand the logic
Can you provide the expected output for the above input
abraham1
Obsidian | Level 7

My requirement is to calculate rank-wise percentage based on cat and subcat. How can I add those two variable into master table for below calculation.

-->Can we create three separate table and store respective category information and then merge it through Ename. 

 

CategorysubcategoryPercentage
Fitness1Fit1x%
 Fit2x%
Fitness2Fit1x%
 Fit4x%
Fitness3Fit1x%
 Fit5x%
ballardw
Super User

To calculate percentages we need to know a numerator and a denominator.

Which is hard to tell from your want (NO NUMBERS which should be based on your example data) and better yet a description of exactly how anything is calculated.

abraham1
Obsidian | Level 7
Can you please guide me how category and sub category will be added to table. I will check pct later. How can I transpose data to get results
mkeintz
PROC Star

Like the others, I also have no idea of the relationship between the table you present and the data you show.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 812 views
  • 1 like
  • 4 in conversation