BookmarkSubscribeRSS Feed
G_I_Jeff
Obsidian | Level 7

I'm not the sharpest SAS programmer. My SAS macro in this statement doesn't seem to be running, or at least is not getting put to the pdf. I don't see anything in the SASLOG referencing the macro as well:

%let rptdate =                                                 
 %sysfunc(intnx(day,%sysfunc(today()), -1),weekdate29.);       
                                                               
proc sql noprint;                                              
 select distinct cpcfname into :type from pdb.rmfintrv;        
quit;                                                          
                                                               
proc sql noprint;                                              
 select distinct system into :systems separated by '|'         
  from pdb.rmfintrv;                                           
 %let nsystems=&sqlobs;                                        
quit;                                                          
                                                               
proc sql;                                                      
 create table user.tempcpu as                                  
 select sysplex label='sysplex',                               
        system label='system',                                 
        hour,                                                  
        min(pctcpuby) as mincpu,                               
        avg(pctcpuby) as avgcpu,                               
        max(pctcpuby) as maxcpu,                               
        min(pctzipby) as minzip,                               
        avg(pctzipby) as avgzip,                               
        max(pctzipby) as maxzip,                               
        min(platbusy) as minplat,                              
        avg(platbusy) as avgplat,                              
        max(platbusy) as maxplat                               
   from pdb.rmfintrv                                           
  group by sysplex, system, hour;                              
                                                               
ods _all_ close;                                               
ods pdf file="/nitc/perf/test/nfccpu.pdf" style=sasweb notoc;  
options leftmargin=.5in rightmargin=.5in orientation=landscape;
                                                            
%let sys=%scan(&systems,1,|);                               
proc sgplot data=user.tempcpu;                              
 where system="&sys";                                       
 title "&type cpu use for &rptdate";                        
  vbar hour / response=maxplat datalabel transparency=0.3   
       legendlabel='max cpu';                               
  vbar hour / response=avgplat datalabel transparency=0.3   
       legendlabel='average cpu';                           
 xaxis label='hour';                                        
 yaxis label='cpu percentage';                              
run;                                                        
                                                            
%macro graph_cpu(nsystems,systems);                         
 %do i=1 %to &nsystems;                                     
  %let sys=%scan(&systems,&i,|);                            
                                                            
   proc sgplot data=user.tempcpu;                           
     where system="&sys";                                   
     title "&sys cpu use for &rptdate";                     
      vbar hour / response=maxcpu datalabel transparency=0.3
           legendlabel='max cpu';                           
      vbar hour / response=avgcpu datalabel transparency=0.3
           legendlabel='average cpu';                       
     vline hour / response=avgzip y2axis                    
           lineattrs=(thickness=2 pattern=solid)            
           legendlabel='average ziip';                      
     xaxis  label='hour';                                   
     yaxis label='cpu percentage';                          
     y2axis label='avg ziip percentage';                    
   run;                                                     
                                                            
 %end;                                                      
%mend graph_cpu;                                            
run;                         
              
ods pdf close;
run;                                         

Also if anyone has any better suggestions please let them fly. The landscaping option doesn't seem to be working either.

2 REPLIES 2
Reeza
Super User
I don't see you calling it anywhere....I'd expect to see something like below, not knowing what the parameters should be obviously.
If you do have that and it doesn't run, please run it with the macro debugging options on (MPRINT, SYMBOLGEN) and include the log.

%graph_cpu(8, 20);
ballardw
Super User

An awful lot things that you code like this:

 %do i=1 %to &nsystems;                                     
  %let sys=%scan(&systems,&i,|);                            
                                                            
   proc sgplot data=user.tempcpu;                           
     where system="&sys";     

Could be done by

Proc sgplot data=user.tempcpu;
   by system;

If you are subsetting data on the same variable you could something like

where system in ("value1" "value2" "value5");

though the data would need to be sorted by the By variable(s) as usual.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 984 views
  • 2 likes
  • 3 in conversation