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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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