BookmarkSubscribeRSS Feed
pacman94
Calcite | Level 5

Hello. I have the following dataset

Group_CategoryGroupTotalFemaleMaleHispanicNotHispanic 
Group AGroupA_1321616230 
Group AGroupA_2301416525 
Group AGroupA_3106464 
Group BGroupB_1109119 
Group BGroupB_2442024440 
Group BGroupB_3602040555 

 

What I would like to do is modify the variable names for all the groups. Something like this to be outputted eventually to csv or excel and merging Group A and B for their corresponding columns _1, _2, _3. 

Category_1Category_2Group A  Group B  
  GroupA_1GroupA_2GroupA_3GroupB_1GroupB_2GroupB_3
Total 323010104460
GenderFemale1614692020
GenderMale1616412440
EthnicityHispanic or Latino256145
EthnicityNot Hispanic or Latino3025494055

i have been having no luck thus far. All I could this is to insert a row in the dataset for each group and then rename the original variable name

 

 

2 REPLIES 2
andreas_lds
Jade | Level 19

Both tables look like reports, not like datasets. Can you post the data used to create the first table? One thing is confusing: the total-line has 32 for GroupA_1, but the rows below sum-up to 64.

pacman94
Calcite | Level 5

Hello. The original data looks like this:

Group_CategoryGroupTotalFemaleMaleHispanicNotHispanic
Group AGroupA_1321616230
Group AGroupA_2301416525
Group AGroupA_3106464
Group BGroupB_1109119
Group BGroupB_2442024440
Group BGroupB_3602040555

Female + Male = Total

Hispanic + Not Hispanic = Total

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 672 views
  • 0 likes
  • 2 in conversation