BookmarkSubscribeRSS Feed
rjcroller
Calcite | Level 5

My input is:

 

PROD,08JUL2017 ,22:30,   57,     21, 36.1,*****        ,   19,
PROD,08JUL2017 ,22:45,   57,     21, 37.4,*****        ,   19,
PROD,08JUL2017 ,23:00,   57,     22, 38.5,*****        ,   18,

 

I wish to average the fifth field and return the highest value. This is an IBM mainframe environment.

5 REPLIES 5
Shmuel
Garnet | Level 18

Please post:

1) A sample of your data

2) output desired

3) your code and what issues do you have

rjcroller
Calcite | Level 5

Name,Interval  ,Intvl,Defin,Rolling,     ,4hr Cap%     ,Inter,Capping,Durati,
----,Date------,Time-,Capac,4hr MSU,     ,0{50}100     ,  MSU, WLM%  ,Cappin,
PROD,29JUL2017 ,22:30,   57,     23, 40.6,*****        ,   26,  N/A  ,  N/A ,
PROD,29JUL2017 ,22:45,   57,     24, 41.9,*****        ,   18,  N/A  ,  N/A ,

 

This is the current output when using Excel:

Average MSU24.61
% > 40 MSU:20.32%
% > 45 MSU:12.43%
% > 48 MSU:8.97%
% > 50 MSU:6.72%
Peak MSU68
% intervals > 75 % of cap24.62%
% intervals > 80 %18.71%
% intervals > 90 %9.34%
% intervals ≥ 100 %0.97%
% intervals capped0.57%
# Intrvls ≥ 60 MSUs39

 

I am new to SAS so I really dont have much in terms of code.

ballardw
Super User

First Read the data into a SAS data set.

If you have done that then we need to know if you need to group the data at all. In your example the Prod and/or Date are likely groups

Do you need a dataset for further processing or a report for people.

I wish to average the fifth field and return the highest value

Seems to imply a two step process that you will need to describe. Such as Average the field grouped by Product then report the maximum of the averages over the whole data set. But again, without knowing which groups to use recommendations may be off target.

 

 

 

Astounding
PROC Star

Assuming you have JCL that defines the file using MYDATA as the DDname:

 

data want;

infile mydata dsd;

length dummy $ 1;

input dummy dummy dummy dummy fifth_field;

keep fifth_field;

run;

 

proc means data=want mean max;

var fifth_field;

run;

rjcroller
Calcite | Level 5

Thanks for all the suggestions.  I have made some progress.  The code thus far is:

 

data want;                                       
infile input dsd;                                
length dummy $ 1;                                
input dummy dummy dummy dummy R4H dummy dummy INT;
keep R4H INT ;                                   
run;                                             

 

proc sql;                         
create table MSU1 as              
select Max(R4H) as r4hmax,        
       Avg(R4H) as r4havg,        
       R4H > 40 as r4hgt40,       
       R4H > 45 as r4hgt45,       
       R4H > 48 as r4hgt48,       
       R4H > 50 as r4hgt50,       
       R4H > 52 as r4hgt52,       
       R4H > 55 as r4hgt55,       
       R4H > 57 as r4hgt57,       
       R4H > 60 as r4hgt60,       
       Avg(INT) as intavg,        
       Max(INT) as intmax,        
       INT > .75*57 as intgt75%,  
       INT > .80*57 as intgt80%   
 from want                        
  where R4H  ;                    
quit;    

 

proc freq data=MSU1 ;                                              
tables R4Havg r4hmax r4hgt40 r4hgt45 r4hgt48 r4hgt50 r4hgt52 r4hgt55
r4hgt57 r4hgt60 intavg intmax intgt75% intgt80%;                   
run;                                                                                         

 

Not completed yet but a start. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 709 views
  • 1 like
  • 4 in conversation