BookmarkSubscribeRSS Feed
fredbell
Fluorite | Level 6
Hi

I would like to be able to return value in stat_val column when stat_name = i_otalktim and value in stat_val when stat_name = i_owraptim

How can this be done?

stat_name stat_val

i_otalktim 100
i_otalktim 500
i_owraptim 300
i_owraptim 200

I would like the output to look like

TotTalk TotWrap

600 500

Thanks

Message was edited by: fredbell

Message was edited by: fredbell Message was edited by: fredbell
1 REPLY 1
RichardH_sas
SAS Employee
If you want to do this without writing code, it's probably going to be a two-step process:

1. Summarize the data by stat_name and whatever other group columns you need (Rep_ID, Region, whatever).
2. Use a Split Columns task on the resulting data to turn two rows into one row with separate columns for Talk and Wrap.

You could also write some DATA step code to do both of these things at once with first./last. processing. You would need a PROC SORT initially to order the data by your grouping columns and stat_name. Someone else might post some sample code here, or you can browse through the following examples with first./last. processing to get you started:

http://support.sas.com/kb/24/745.html
http://support.sas.com/kb/?qt=contenttype:%22Sample%22+&qp=url:/kb/&la=en&qm=3&ct=53030&col=suppprd

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 980 views
  • 0 likes
  • 2 in conversation