BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Raj00007
Calcite | Level 5

i Have a data like this 

Obs ACTUAL PREDICT COUNTRY REGION DIVISION PRODTYPE PRODUCT QUARTER YEAR MONTH123456789101112131415161718192021222324252627282930
$1,802$1,760UKEASTCOMMERCIALFURNITURESOFA11993Jan
$1,864$861UKEASTCOMMERCIALFURNITURESOFA11993Feb
$1,464$1,579UKEASTCOMMERCIALFURNITURESOFA11993Mar
$763$670UKEASTCOMMERCIALFURNITURESOFA21993Apr
$1,244$1,186UKEASTCOMMERCIALFURNITURESOFA21993May
$1,039$1,146UKEASTCOMMERCIALFURNITURESOFA21993Jun
$1,428$1,232UKEASTCOMMERCIALFURNITURESOFA31993Jul
$956$686UKEASTCOMMERCIALFURNITURESOFA31993Aug
$1,426$1,203UKEASTCOMMERCIALFURNITURESOFA31993Sep
$1,330$991UKEASTCOMMERCIALFURNITURESOFA41993Oct
$936$1,257UKEASTCOMMERCIALFURNITURESOFA41993Nov
$1,024$843UKEASTCOMMERCIALFURNITURESOFA41993Dec
$276$715UKEASTCOMMERCIALFURNITURESOFA11994Jan
$565$902UKEASTCOMMERCIALFURNITURESOFA11994Feb
$143$560UKEASTCOMMERCIALFURNITURESOFA11994Mar
$676$1,215UKEASTCOMMERCIALFURNITURESOFA21994Apr
$1,265$551UKEASTCOMMERCIALFURNITURESOFA21994May
$493$1,016UKEASTCOMMERCIALFURNITURESOFA21994Jun
$841$575UKEASTCOMMERCIALFURNITURESOFA31994Jul
$522$860UKEASTCOMMERCIALFURNITURESOFA31994Aug
$1,480$1,090UKEASTCOMMERCIALFURNITURESOFA31994Sep
$803$1,079UKEASTCOMMERCIALFURNITURESOFA41994Oct
$940$351UKEASTCOMMERCIALFURNITURESOFA41994Nov
$1,326$1,590UKEASTCOMMERCIALFURNITURESOFA41994Dec
$503$1,559UKEASTCOMMERCIALFURNITUREBED11993Jan
$496$472UKEASTCOMMERCIALFURNITUREBED11993Feb
$950$1,198UKEASTCOMMERCIALFURNITUREBED11993Mar
$1,585$1,452UKEASTCOMMERCIALFURNITUREBED21993Apr
$345$1,024UKEASTCOMMERCIALFURNITUREBED21993May
$1,528$730UKEASTCOMMERCIALFURNITUREBED21993Jun

 

 

 

i want it to convert like this how?

 

 

YEAR QUARTER BED CHAIR DESK SOFA TABLE
1993 1 $33,486 $34,644 $37,159 $40,722 $39,126
1993 2 $38,460 $35,087 $35,516 $38,099 $37,662
1993 3 $37,339 $36,988 $36,902 $41,470 $31,784
1993 4 $40,093 $41,905 $37,902 $35,605 $36,505
1994 1 $32,602 $37,496 $35,850 $31,943 $37,100
1994 2 $35,234 $36,590 $35,475 $37,870 $37,267
1994 3 $38,428 $36,379 $35,644 $32,741 $35,433
1994 4 $39,928 $35,337 $37,410 $36,741 $29,478

i tried something like this, but it didn't worked.

proc sort data = sale out=sale1;
by year quarter;run;

proc transpose data = sale1 out=sale2;
by year quarter;
id product;
var Actual;
run; 
proc print;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

As a report:

proc report data=have;
column year quarter actual,product;
define year / group;
define quarter / group;
define product / "" across;
define actual / "" analysis sum;
run;

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Do you need the output as a table to place in a report or document? Or do you need the output as a SAS data set?

 

It would be very helpful if you can provide data in this format from now on. We can't use screen captures to produce a working data set that we can use when we are writing code.

--
Paige Miller
Kurt_Bremser
Super User

First, summarize:

proc summary data=have;
class year quarter product;
var actual;
output out=sum sum()=;
run;

then transpose

proc transpose
  data=sum
  out=want (drop=_:)
;
by year quarter;
id product;
var actual;
run;

Untested, for lack of usable data.

For tested code, supply example data in a working data step with datalines that creates your dataset.

Post the code into a window opened with the "little running man" button next to the one indicated:

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

Kurt_Bremser
Super User

As a report:

proc report data=have;
column year quarter actual,product;
define year / group;
define quarter / group;
define product / "" across;
define actual / "" analysis sum;
run;
RichardDeVen
Barite | Level 11

Instead of a transposed data set you might consider creating a cross tabulation report.

 

The data appears to be very similar to sample data set SASHELP.PRDSALE so I will use that in the following example:

 

ods html file='sales.html' style=plateau;

title 'Actual sales, by year, all countries';
title2 'TABULATE';
proc tabulate data=sashelp.prdsale;
  class year quarter product;
  var actual;
  table year*quarter,product=''*actual=''*sum=''*f=dollar12./nocellmerge;
run;

title2 'REPORT';
proc report data=sashelp.prdsale;
  column year quarter actual,product;
  define year/group;
  define quarter/group;
  define product/' ' across;
  define actual/' ' format=dollar12.;
run;

ods html close;

Image of HTML output

RichardADeVenezia_0-1606137837096.png

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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