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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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