BookmarkSubscribeRSS Feed
FerGui1
Fluorite | Level 6

Hello,

I have a SAS output like the one showing in table 1 and i would like to format it so that I have the two tables shown in tables 2 and 3. Any assistance on this will be greatly appreciated.

 

table 1

ShelfCategoryArticleValue
AOfficeArt154.566
AOfficeArt247.33333
SharedOfficeArt148.2
SharedOfficeArt250.18333
BOfficeArt154.9133
BOfficeArt251.646
AHomeArt150.18
AHomeArt246.11333
SharedHomeArt154.913
SharedHomeArt251.64667
BHomeArt142.9
BHomeArt249.96667

 

table2

Office   
ArticleSharedAB
Art148.254.654.9
Art250.247.351.6

 

table 3

Home   
ArticleSharedAB
Art154.950.242.9
Art251.646.150.0
6 REPLIES 6
PaigeMiller
Diamond | Level 26

UNTESTED CODE

 

proc report data=have;
    by category;
    columns article shelf,value;
    define article/group;
    define shelf/across;
    define value/sum format=best8.1;
run;
--
Paige Miller
FerGui1
Fluorite | Level 6

Hi PaigeMiller,

Thank you so much for your assistance. I run your proposed coding and got the output below. I will still need to:

1. Sort the shelf columns so that it shows in the order Shared, A, and B

2. Replace the 'Value' row by the shelf headings (Shared, A, and B)

3. Eliminate the 'Shelf' row

4. Round all the values to 1 decimal place

Could you help on that?

 

FerGui1_0-1635870514145.png

 

PaigeMiller
Diamond | Level 26

At this point, I request that you provide your data as SAS data step code (instructions), rather than as a screen capture, so I can actually work with it.

--
Paige Miller
FerGui1
Fluorite | Level 6

Hi, 

Is this what you need?

 

data tryout1;
INPUT Shelf $ Category $ Article $ Value;
CARDS;
A Office Art1 54.566
A Office Art2 47.3333333
Shared Office Art1 48.2
Shared Office Art2 50.1833333
B Office Art1 54.9133
B Office Art2 51.646
A Home Art1 50.18
A Home Art2 46.1133333
Shared Home Art1 54.913
Shared Home Art2 51.6466667
B Home Art1 42.9
B Home Art2 49.9666667
;
proc sort data=tryout1; by category;
proc report data=tryout1;
by category;
columns article shelf,value;
define article/group;
define shelf/across;
define value/sum format=best8.1;
run;

PaigeMiller
Diamond | Level 26
data tryout2;
    set tryout1(where=(shelf='Shared')) tryout1(where=(shelf^='Shared'));
run;
proc sort data=tryout2;
    by category;
run;

proc report data=tryout2;
    by category;
    columns ("Article" article) (" " shelf),(" " value);
    define article/group ' ';
    define shelf/across order=data ' ';
    define value/sum format=8.1 ' ';
run;
--
Paige Miller
FerGui1
Fluorite | Level 6

PaigeMiller,

It works just as I needed.

Thank you so much!

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 508 views
  • 1 like
  • 2 in conversation