DATA Step, Macro, Functions and more

Proc Report

Accepted Solution Solved
Reply
Contributor
Posts: 64
Accepted Solution

Proc Report

I have a dataset below:

RegionIDCompanyGroupCount
East12345 XYZCustomer7
East45678 ABCCustomer7
East45677 IUTACustomer7
East23456 JHUYProvider9
East09876IOPUProvider9
West89765BNJKCustomer12
West76545OPOUCustomer12
West32378YUIOSupplier10
West35357IOPIProvider15
West72348RTYUProvider15

I want the output in the following format using proc report.

               Region=East

ID           Company   Group           Count

12345     XYZ         

45678     ABC         

45677     IUTA         

--------------------------------------------------------------

                              CUSTOMER     7

--------------------------------------------------------------

23456     JHUY

09876     IOPU

-------------------------------------------------------------

                              PROVIDER     9

-------------------------------------------------------------

                    Region=West

ID          Company          Group          Count    

89765     BNJK           

76545     OPOU         

---------------------------------------------------------------

                              CUSTOMER     12

---------------------------------------------------------------

I am currently using the below code which is not working out for me. Would appreciate the inputs.

proc report data=test headline headskip nowindows;

by region;

column region ID Company Group Count;

define region/noprint;

define Group/group;

break after count/summarize;

define count/group;

run;


Accepted Solutions
Solution
‎02-08-2015 05:59 AM
Super User
Posts: 10,047

Re: Proc Report

Posted in reply to sasmaverick

How about :

data have;
input Region $     ID     Company $     Group $     Count     ;
cards;
East     12345     XYZ     Customer     7
East     45678     ABC     Customer     7
East     45677     IUTA     Customer     7
East     23456     JHUY     Provider     9
East     09876     IOPU     Provider     9
West     89765     BNJK     Customer     12
West     76545     OPOU     Customer     12
West     32378     YUIO     Supplier     10
West     35357     IOPI     Provider     15
West     72348     RTYU     Provider     15
;
run;
options missing=' ';
proc report data=have headline headskip nowindows ;
by region;
column region ID Company Group Count _Group _Count;
define region/noprint;
define id/display;
define company/display;
define Group/display order noprint;
define count/analysis mean noprint;
define _Group/computed 'Group';
define _count/computed 'count';
compute _Group/character length=20;
endcomp;
compute after group;
_Group=Group;
_count=count.mean;
endcomp;
break after group/summarize;
run;




Xia Keshan

View solution in original post


All Replies
Solution
‎02-08-2015 05:59 AM
Super User
Posts: 10,047

Re: Proc Report

Posted in reply to sasmaverick

How about :

data have;
input Region $     ID     Company $     Group $     Count     ;
cards;
East     12345     XYZ     Customer     7
East     45678     ABC     Customer     7
East     45677     IUTA     Customer     7
East     23456     JHUY     Provider     9
East     09876     IOPU     Provider     9
West     89765     BNJK     Customer     12
West     76545     OPOU     Customer     12
West     32378     YUIO     Supplier     10
West     35357     IOPI     Provider     15
West     72348     RTYU     Provider     15
;
run;
options missing=' ';
proc report data=have headline headskip nowindows ;
by region;
column region ID Company Group Count _Group _Count;
define region/noprint;
define id/display;
define company/display;
define Group/display order noprint;
define count/analysis mean noprint;
define _Group/computed 'Group';
define _count/computed 'count';
compute _Group/character length=20;
endcomp;
compute after group;
_Group=Group;
_count=count.mean;
endcomp;
break after group/summarize;
run;




Xia Keshan

Contributor
Posts: 64

Re: Proc Report

Thanks a ton Xia! Worked perfectly!

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 196 views
  • 0 likes
  • 2 in conversation