BookmarkSubscribeRSS Feed
jawon
Fluorite | Level 6
Of course this will be easier to explain with an example. This is what I'm starting with. The last 4 variables are numeric, representing quantity and revenue, each separated into 2 different groups...

Region | State | County | City | Qty_CB | Qty_VB | Revenue_CB | Revenue_VB
West | CA | LA | LA | 1 | 0 | $111 | $0
Midwest | IL | Cook | Chicago | 3 | 4 | $777 | $888

I want to transpose so that I end up with a new "Category" field that captures the 2 groups, and then have just one Qty field and one Revenue field...

Region | State | County | City | Category | Qty | Revenue
West | CA | LA | LA | CB | 1 | $111
West | CA | LA | LA | VB | 0 | $0
Midwest | IL | Cook | Chicago | CB | 3 | $777
Midwest | IL | Cook | Chicago | CB | 4 | $888

I think the prob I'm encountering is trying to transpose both Qty and Revenue fields, as opposed to just one. Any suggestions? Thanks much!
4 REPLIES 4
LinusH
Tourmaline | Level 20
By using a data step you will have full control of your output. No problem there I believe.

/Linus
Data never sleeps
GertNissen
Barite | Level 11
Hi Jawon

I don't have access to SAS right now, so please test the follwing 🙂

data tworows(keep=Region State County City Category Qty Revenue);
set onerows(keep=Region State County City Qty_CB Qty_VB Revenue_CB Revenue_VB);
category = 'CB';
Qty = Qty_CB ;
Revenue = Revenue_CB ;
output;
category = 'VB';
Qty = Qty_VB ;
Revenue = Revenue_VB ;
output;
run;
jawon
Fluorite | Level 6
Excellent. Thank you. I think I was overthinking this!
R_Win
Calcite | Level 5
good

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 714 views
  • 0 likes
  • 4 in conversation