Desktop productivity for business analysts and programmers

CASE Question

Posts: 73

CASE Question


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


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:
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation