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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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