Desktop productivity for business analysts and programmers

CASE Question

Reply
Contributor
Posts: 73

CASE Question

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
SAS Employee
Posts: 149

Re: CASE Question

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
Ask a Question
Discussion stats
  • 1 reply
  • 105 views
  • 0 likes
  • 2 in conversation