Help using Base SAS procedures

Proc Report and Group Percentages

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Proc Report and Group Percentages


Hi, 

 

Can I please get some help with this.

The Destination Table contains a list of customers who holidayed last year to DESTINATION Europe, or remained in NZ for their holidays.  A customer may have had holidays in both Europe and NZ. The layout for the table is shown below:  

 I would like to create a report that shows the precentage of customers, who went to Europe last year, but based on Customer_Age: 

20 – 29, 30 –39, 40 – 49, 50+.

And the report should only show the Age Range and the Percentage of Customers who went to Europe for their holiday. 

 

 

How can I implement an Age_Range in this report? Would I be right to do it with

PROC FORMAT?

 

Something like:

 

Proc format ;

value  Customer_Age;

18 - 29 = ' Age Range 20 – 29’

30 -  44 = ' Age Range 30-39'

45 - 59 = ' Age Range  40 49'

60 -  high  = ' Age Range  50+';

run;

 

and then I would start like below, but I am not sure how to link my Age Range . I thought the Proc format creates the Group that I can define and analyse using a computing block. But I am not really sure how it connects.

Help much appreciated

 

Proc Report Data = Holiday

headline headskip;

title1 "Customer Holiday Report";

COLUMN CUSTOMER_AGE('_Destination_'  Destination = pct);

DEFINE CUSTOMER_AGE /GROUP FORMAT=8. ;

DEFINE pct /GROUP FORMAT=8. FORMAT=PERCENT8. ;

RBREAK AFTER /SUMMARIZE UL OL; RUN;

 

 

CUSTOMER_NUMBER

CUSTOMER_AGE

DESTINATION

123

27

NZ

123

27

Europe

124

42

Europe

125

33

NZ

126

45

Europe

127

60

NZ

128

45

Europe

129

62

Europe

130

33

Europe

131

58

Europe

132

34

Europe

133

49

Europe

133

49

NZ

134

33

Europe

135

45

NZ

136

60

NZ

137

45

NZ

138

62

NZ

139

33

NZ

140

45

Europe

141

60

Europe

142

45

Europe

143

62

Europe

144

33

Europe

 


Accepted Solutions
Solution
‎09-12-2017 04:25 AM
Super User
Super User
Posts: 9,599

Re: Proc Report and Group Percentages

You can create a dataset from your proc means:

proc means...;
 ...
  output out=want...;
run;

proc report data=want...;
...

And report out that.  

View solution in original post


All Replies
Super User
Super User
Posts: 9,599

Re: Proc Report and Group Percentages

Why not do a simple proc sql group by, then proc report that?  

New Contributor
Posts: 4

Re: Proc Report and Group Percentages

I looked itno Proc means, which basically gives me the perecentages. 

I don't quite understand how to link that to proc report. 

 

Solution
‎09-12-2017 04:25 AM
Super User
Super User
Posts: 9,599

Re: Proc Report and Group Percentages

You can create a dataset from your proc means:

proc means...;
 ...
  output out=want...;
run;

proc report data=want...;
...

And report out that.  

New Contributor
Posts: 4

Re: Proc Report and Group Percentages

That is all ?! - great, so easy. 

Thanks!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 318 views
  • 0 likes
  • 2 in conversation