BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Reeza
Super User

@Tom wrote:

Do both of your graphs appear on the same page?  A page can only have one header area, which is where titles are placed.


Or unless you use BODYTITLE which puts it in the main page area. If it's in the header, well, each page only has one header so I'm assuming each graph will go to a separate page anyways so each would have it's own header. Unless STARTPAGE was also set.

Tom
Super User Tom
Super User

Can you post a working data step for your sample data? As data that works with your macro?

122   %Quarter(CHECK,TLFPL  ,Q, Inflation-Adjusted Dollars, Quadrimester Trend for Financial and Legal
122 ! Affairs );
MPRINT(QUARTER):   proc sql;
MPRINT(QUARTER):   create table TLFPL_Q as select mean(I_PreResYr1stT_TLFPL) as Pre_Q1
,mean(I_PreResYr2ndT_TLFPL) as Pre_Q2 ,mean(I_PreResYr3rdT_TLFPL) as Pre_Q3 ,mean(I_PostResYr1stT_TLFPL)
as Pos_Q1 ,mean(I_PostResYr2ndT_TLFPL) as Pos_Q2 ,mean(I_PostResYr3rdT_TLFPL) as Pos_Q3 from CHECK where
TRICHOT_1YR ne . and Full_Alc_Exp = 1 group by TRICHOT_1YR ;
ERROR: The MEAN summary function requires a numeric argument.
ERROR: The MEAN summary function requires a numeric argument.
ERROR: The MEAN summary function requires a numeric argument.
ERROR: The MEAN summary function requires a numeric argument.
ERROR: The MEAN summary function requires a numeric argument.
ERROR: The MEAN summary function requires a numeric argument.
ERROR: The following columns were not found in the contributing tables: I_PostResYr1stT_TLFPL,
       I_PostResYr2ndT_TLFPL, I_PostResYr3rdT_TLFPL, I_PreResYr1stT_TLFPL, I_PreResYr2ndT_TLFPL,
       I_PreResYr3rdT_TLFPL.
MPRINT(QUARTER):   quit;
ballardw
Super User

When I run your data step for work.check I get lots of errors.

16   data WORK.CHECK;
17     infile datalines dsd truncover;
18     input PID:BEST. TRICHOT_1YR:BEST12. Full_ALC_Exp:BEST12. I_PreResYr1stTri_consume:32.
18 ! I_PreResYr2ndTri_consume:32. I_PreResYr3rdTri_consume:32.;
19     format PID BEST. TRICHOT_1YR BEST12. Full_ALC_Exp BEST12.;
20     label PID="SUBJID#" TRICHOT_1YR="RA 273, UR 140, RNA 80, Missing 123" Full_ALC_Exp="1 year
20 ! complete TLFB alcohol and spending data as well: 1=Yes, 0=No (number of yes is 412)";
21   datalines;

NOTE: Invalid data for PID in line 22 1-46.
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--
22         2609 . 0 1315.499163 1031.2530601 86.162580581
PID=. TRICHOT_1YR=. Full_ALC_Exp=. I_PreResYr1stTri_consume=. I_PreResYr2ndTri_consume=.
I_PreResYr3rdTri_consume=. _ERROR_=1 _N_=1
NOTE: Invalid data for PID in line 23 1-36.
23         2670 . 0 . 689.00068096 689.00068096
PID=. TRICHOT_1YR=. Full_ALC_Exp=. I_PreResYr1stTri_consume=. I_PreResYr2ndTri_consume=.
I_PreResYr3rdTri_consume=. _ERROR_=1 _N_=2
NOTE: Invalid data for PID in line 24 1-47.
24         2711 . 0 1856.2984793 1981.3589366 1570.1859747
PID=. TRICHOT_1YR=. Full_ALC_Exp=. I_PreResYr1stTri_consume=. I_PreResYr2ndTri_consume=.
I_PreResYr3rdTri_consume=. _ERROR_=1 _N_=3
NOTE: Invalid data for PID in line 25 1-47.
25         2713 . 0 8835.8159545 9291.5286175 8472.5269738
PID=. TRICHOT_1YR=. Full_ALC_Exp=. I_PreResYr1stTri_consume=. I_PreResYr2ndTri_consume=.
I_PreResYr3rdTri_consume=. _ERROR_=1 _N_=4
NOTE: Invalid data for PID in line 26 1-46.
26         2724 . 0 1727.4392094 1711.489481 1700.5554834
PID=. TRICHOT_1YR=. Full_ALC_Exp=. I_PreResYr1stTri_consume=. I_PreResYr2ndTri_consume=.
I_PreResYr3rdTri_consume=. _ERROR_=1 _N_=5
NOTE: Invalid data for PID in line 27 1-45.
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--
27         2743 . 0 1344.548653 1076.604699 1441.1998341
PID=. TRICHOT_1YR=. Full_ALC_Exp=. I_PreResYr1stTri_consume=. I_PreResYr2ndTri_consume=.
I_PreResYr3rdTri_consume=. _ERROR_=1 _N_=6
NOTE: Invalid data for PID in line 28 1-47.
28         2776 . 0 1690.7046881 1690.7046881 1690.7046881
PID=. TRICHOT_1YR=. Full_ALC_Exp=. I_PreResYr1stTri_consume=. I_PreResYr2ndTri_consume=.
I_PreResYr3rdTri_consume=. _ERROR_=1 _N_=7
NOTE: Invalid data for PID in line 29 1-47.
29         2812 . 0 342.74922238 338.67444067 338.67444067
PID=. TRICHOT_1YR=. Full_ALC_Exp=. I_PreResYr1stTri_consume=. I_PreResYr2ndTri_consume=.
I_PreResYr3rdTri_consume=. _ERROR_=1 _N_=8
NOTE: Invalid data for PID in line 30 1-46.
30         2827 . 0 1085.1836237 1148.959131 1085.1836237
PID=. TRICHOT_1YR=. Full_ALC_Exp=. I_PreResYr1stTri_consume=. I_PreResYr2ndTri_consume=.
I_PreResYr3rdTri_consume=. _ERROR_=1 _N_=9
NOTE: Invalid data for PID in line 31 1-47.
31         2854 . 0 2128.9891276 2407.0103218 2128.9891276
PID=. TRICHOT_1YR=. Full_ALC_Exp=. I_PreResYr1stTri_consume=. I_PreResYr2ndTri_consume=.
I_PreResYr3rdTri_consume=. _ERROR_=1 _N_=10
NOTE: The data set WORK.CHECK has 10 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.04 seconds


joebacon
Pyrite | Level 9

I apologize! I ran the macro twice as the variables are slightly differently named - "Tri" in the middle or "T". This should be working data with minimal missing values that will work with that macro.

 

data WORK.CHECK;
  infile datalines dsd truncover;

input PID:BEST. TRICHOT_1YR:BEST12. Full_ALC_Exp:BEST12. I_PreResYr1stT_TLFPL:32. I_PreResYr1stT_DurInsHouse:32. I_PreResYr2ndT_TLFPL:32. I_PreResYr2ndT_DurInsHouse:32. I_PreResYr3rdT_TLFPL:32. I_PreResYr3rdT_DurInsHouse:32. I_PostResYr1stT_TLFPL:32. I_Pos
tResYr1stT_DurInsHouse:32. I_PostResYr2ndT_TLFPL:32. I_PostResYr2ndT_DurInsHouse:32. I_PostResYr3rdT_TLFPL:32. I_PostResYr3rdT_DurInsHouse:32.;
  format PID BEST. TRICHOT_1YR BEST12. Full_ALC_Exp BEST12.;
  label PID="SUBJID#" TRICHOT_1YR="RA 273, UR 140, RNA 80, Missing 123" Full_ALC_Exp="1 year complete TLFB alcohol and spending data as well: 1=Yes, 0=No (number of yes is 412)";
datalines;
2605 1 1 11166.131119 11707.922833 12561.772509 10928.509261 12561.772509 11462.570587 11078.105658 12811.94131 12462.743865 9628.9003835 1 9259.5419486
2623 1 1 . . 1 2685.3534532 21.72939979 3928.259141 83.26388002 4293.022259 62.697910015 2363.3350257 83.26388002 1939.9124927
2631 1 1 1 646.6652924 1 646.6652924 1 896.86059321 138.1064667 973.05039329 1 2373.0558331 1 6704.8905622
2657 1 1 14040.469694 4417.4101195 13694.979697 5280.2878307 14264.789439 5186.8225015 12743.455645 4016.3032487 13436.501413 5197.3785994 13779.267579 8491.561087
2663 1 1 1 2546.9228145 1 2059.4455187 1 2059.4455187 1 2012.0441376 1 2014.4096266 1 2463.6632996
2666 1 1 1 1623.2340472 788.71719202 1486.0301725 1 1348.8262979 1 1574.8386887 225.96429056 1719.9220147 547.34184851 2159.9029707
2674 1 1 1 1666.8164544 1 1666.8164544 1 1159.9691999 1 1394.0364786 1 2060.1108743 1 2060.1108743
2675 1 1 1 5634.4296762 1 4270.461746 1 3156.6891166 1 3790.8682689 1 1869.9402586 1 2388.179488
2684 1 1 5734.1577391 6168.4849518 6121.5764016 6168.4849518 5354.9893778 7782.6481828 14017.284406 9847.0086851 14280.775613 8314.3848387 16531.92669 8102.3742713
2688 1 1 1 1970.8471458 1 1 1 969.4979386 138.1064667 3099.0337125 1325.8323664 3213.3545793 983.45009779 9467.7676662
;;;;
NOTE: There were 10 observations read from the data set WORK.CHECK.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

 

@Tom 

 

Tom
Super User Tom
Super User

That seems a little close to what the macro is expecting (once you remove the unwanted DSD option from the INFILE statement).

But still it does not have everything the macro is expecting.

The output of the PROC TRANSPOSE step does not produce any COL2 or COL3 variable to be renamed.

MPRINT(QUARTER):   data TLFPL_Q ;
MPRINT(QUARTER):   set TLFPL_Q ;
MPRINT(QUARTER):   rename COL1 =RA COL2 =UR COL3 =RNA;
MPRINT(QUARTER):   Quadrimester = substr(_NAME_,5,2);
MPRINT(QUARTER):   if substr(_NAME_,1,3)="Pos" then Year="Post Resolution";
MPRINT(QUARTER):   if substr(_NAME_,1,3)="Pre" then Year="Pre Resolution";
MPRINT(QUARTER):   drop _NAME_;
MPRINT(QUARTER):   run;

WARNING: The variable COL2 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable COL3 in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 6 observations read from the data set WORK.TLFPL_Q.
NOTE: The data set WORK.TLFPL_Q has 6 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


MPRINT(QUARTER):   ods graphics / reset=all border=off width=700px height=500px;
MPRINT(QUARTER):   title height=0.2in "Quadrimester Trend for Financial and Legal Affairs";
MPRINT(QUARTER):   proc sgpanel data=TLFPL_Q;
MPRINT(QUARTER):   panelby Year/sort=(descformat) headerattrs=(weight=bold);
MPRINT(QUARTER):   series x=Quadrimester y=RA/ markers markerattrs=(symbol=circlefilled size=3pct
color=blue) lineattrs=(color=blue thickness=4 pattern=longdash) ;
ERROR: Variable UR not found.
MPRINT(QUARTER):   series x=Quadrimester y=UR/ markers markerattrs=(symbol=circlefilled size=3pct
color=red) lineattrs=(color=red thickness=4 pattern=ShortDashDot) ;
ERROR: Variable RNA not found.
MPRINT(QUARTER):   series x=Quadrimester y=RNA/ markers markerattrs=(symbol=circlefilled size=3pct
color=green) lineattrs=(color=green thickness=4 pattern=solid) ;
MPRINT(QUARTER):   rowaxis label="Inflation-Adjusted Dollars" labelattrs=(size=12pt weight=bold)
valueattrs=(size=12pt weight=bold);
MPRINT(QUARTER):   colaxis label=' ' labelattrs=(size=12pt weight=bold) valueattrs=(size=12pt weight=bold);
MPRINT(QUARTER):   keylegend /valueattrs=(Size=12 weight=bold);
MPRINT(QUARTER):   run;
joebacon
Pyrite | Level 9

Man, I commend you for sticking with this as long as you could to help me. I didn't want to give you the full dataset as its quite large.

 

I handpicked these PID's to make sure there are varying Trichot_1Yr so you get 3 columns.

 

data WORK.CHECK;
  infile datalines  truncover;

input PID:BEST. TRICHOT_1YR:BEST12. Full_ALC_Exp:BEST12. I_PreResYr1stT_TLFPL:32. I_PreResYr1stT_DurInsHouse:32. I_PreResYr2ndT_TLFPL:32. I_PreResYr2ndT_DurInsHouse:32. I_PreResYr3rdT_TLFPL:32. I_PreResYr3rdT_DurInsHouse:32. I_PostResYr1stT_TLFPL:32. I_Pos
tResYr1stT_DurInsHouse:32. I_PostResYr2ndT_TLFPL:32. I_PostResYr2ndT_DurInsHouse:32. I_PostResYr3rdT_TLFPL:32. I_PostResYr3rdT_DurInsHouse:32.;
  format PID BEST. TRICHOT_1YR BEST12. Full_ALC_Exp BEST12.;
  label PID="SUBJID#" TRICHOT_1YR="RA 273, UR 140, RNA 80, Missing 123" Full_ALC_Exp="1 year complete TLFB alcohol and spending data as well: 1=Yes, 0=No (number of yes is 412)";
datalines;
2605 1 1 11166.131119 11707.922833 12561.772509 10928.509261 12561.772509 11462.570587 11078.105658 12811.94131 12462.743865 9628.9003835 1 9259.5419486
2858 1 1 1388.517443 4424.1157183 2924.10987 4222.5505804 3328.5739468 4312.0054148 2730.681917 2168.4999609 1300.0109658 2391.6101145 1104.1285743 2592.6901461
6338 1 1 1 3469.2203908 1 2775.5763127 153.6345391 2081.9322345 452.12863105 4834.3025103 407.01576795 2695.0336416 6.012540345 2604.3434301
6360 1 1 1 1291.126601 1 1033.1012808 1 861.98296562 1 1444.4520149 1 1313.9125079 1 1223.4778124
2638 2 1 1 1 1 1 1 833.56925292 275.2129334 1244.6006528 549.4258668 861.40720293 789.36218353 861.40720293
2680 2 1 1 1 222.11359776 1 . . 1 1 1 263.47858875 1 1
5063 2 1 3036.70267 5460.0842347 12893.195568 1811.5354958 708.75239392 1065.096051 2961.5388348 23270.379643 8158.0570494 2200.0573564 8053.2596138 2925.4710269
2822 3 1 4081.288449 1968.5412537 4081.288449 3928.7488641 4081.288449 2275.2663763 4223.9541787 2449.1101817 4021.3172219 10861.549044 4061.8446133 11396.164002
5155 3 1 3289.967007 3243.9862507 4294.9291481 6558.8840384 3289.967007 6439.902004 3220.9384279 6038.407469 3767.9332221 5703.232567 3282.9687654 5703.232567
6207 3 1 1 17451.859419 6779.3136817 98733.113819 1 11065.349002 6962.005 12244.89575 8663.584 14332.7113 9127.651 10562.465
;;;;
Tom
Super User Tom
Super User

So it looks like perhaps you are asking about the NOGTITLE option on the ODS RTF statement?

I commented out the extra two statements in your macro so that it ran and then ran it twice once with and without that option.

ods rtf file='c:\downloads\test1.rtf' nogtitle;
%Quarter(CHECK,TLFPL  ,Q, Inflation-Adjusted Dollars, Quadrimester Trend for Financial and Legal Affairs );
ods rtf close;
ods rtf file='c:\downloads\test2.rtf' gtitle;
%Quarter(CHECK,TLFPL  ,Q, Inflation-Adjusted Dollars, Quadrimester Trend for Financial and Legal Affairs );
ods rtf close;

image.pngimage.png

joebacon
Pyrite | Level 9
Much thanks, Tom.

I do have two questions for my learning. Does bodytitle not function the same way?
Secondly, on your SAS report, does it show the same data points plotting for each of the graphs (i.e. the graphs look exactly the same with different titles)?
joebacon
Pyrite | Level 9
Also, which two lines did you comment out because I am still getting no title with gtitle but do get the title style you get with nogtitle.
Tom
Super User Tom
Super User

Perhaps the title just doesn't fit. Or the font is so tiny you can't see it?

Eliminate the macro and debug the RTF/SGPLOT issues first.

Then you can re-create the macro.

joebacon
Pyrite | Level 9

Thank you good sir. Will do.

joebacon
Pyrite | Level 9

@Reeza @ballardw Thank you again! Update: I needed both the nogtitle and bodytitle for it to print the titles on each page for each graph!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 26 replies
  • 3458 views
  • 11 likes
  • 4 in conversation