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

I have a data set that look as follows:

 

yearmonthaccrual
201722
201731
201740
201750
201760
201774
201781
201794
2017105
2017114
2017124
2018110
201828
201836
201849

 

my proc report that reads as:

 

proc report data=accrualwithzeroes;
   columns (month year,accrual);
   define month/'month' group order=internal format=months.;
   define year/'accrual' across;
   define accrual/'n';
run;

 

With the results as follows

 

 

 accrual
 20172018
monthnn
Jan.10
Feb28
Mar16
Apr09
May0.
Jun0.
Jul4.
Aug1.
Sep4.
Oct5.
Nov4.
Dec4.
  

 

Which looks mostly how I want it to, except I do want the 'n' to be there.  But, changing it to two single quotes in the define statement still leaves an empty cell there.

 

Is there a way in the report statement to put the 2017 and 2018 where the "n" is?

Or just do away with that column altogether and move the "month" title up in to the earlier row?

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  Yes, there are 2 ways to do what you want. Both methods are shown below.

Cynthia

 

data testdata;
  infile datalines;
  input year month accrual;
datalines;
2017	2	2
2017	3	1
2017	4	0
2017	5	0
2017	6	0
2017	7	4
2017	8	1
2017	9	4
2017	10	5
2017	11	4
2017	12	4
2018	1	10
2018	2	8
2018	3	6
2018	4	9
;
run;
  
proc report data=testdata;
   title 'Method 1 -- put numeric variable above ACROSS variable';
   columns (month accrual,year);
   define month/'month' group order=internal ;
   define year/'accrual' across;
   define accrual/' ';
run;
   
proc report data=testdata;
   title 'Method 2 -- move header for month into column statement';
   columns ('Month' month) year,accrual;
   define month/' ' group order=internal ;
   define year/'accrual' across;
   define accrual/' ';
run;

 

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi:

  Yes, there are 2 ways to do what you want. Both methods are shown below.

Cynthia

 

data testdata;
  infile datalines;
  input year month accrual;
datalines;
2017	2	2
2017	3	1
2017	4	0
2017	5	0
2017	6	0
2017	7	4
2017	8	1
2017	9	4
2017	10	5
2017	11	4
2017	12	4
2018	1	10
2018	2	8
2018	3	6
2018	4	9
;
run;
  
proc report data=testdata;
   title 'Method 1 -- put numeric variable above ACROSS variable';
   columns (month accrual,year);
   define month/'month' group order=internal ;
   define year/'accrual' across;
   define accrual/' ';
run;
   
proc report data=testdata;
   title 'Method 2 -- move header for month into column statement';
   columns ('Month' month) year,accrual;
   define month/' ' group order=internal ;
   define year/'accrual' across;
   define accrual/' ';
run;

 

jtcowder
Fluorite | Level 6

Cynthia

Thank you so much.

That was extremely helpful.

 

Jim

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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