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.
Please post:
1) A sample of your data
2) output desired
3) your code and what issues do you have
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 MSU | 24.61 |
% > 40 MSU: | 20.32% |
% > 45 MSU: | 12.43% |
% > 48 MSU: | 8.97% |
% > 50 MSU: | 6.72% |
Peak MSU | 68 |
% intervals > 75 % of cap | 24.62% |
% intervals > 80 % | 18.71% |
% intervals > 90 % | 9.34% |
% intervals ≥ 100 % | 0.97% |
% intervals capped | 0.57% |
# Intrvls ≥ 60 MSUs | 39 |
I am new to SAS so I really dont have much in terms of code.
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.
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;
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.