BookmarkSubscribeRSS Feed
rkumar23
Calcite | Level 5


I have a month of data as below And I need to calculate the Average on VAR1 per day(date) by DISTNAME .....any thought?

DATE       TIME    X      Y     Z         DISTNAME     VAR1    THRESHOLD

01OCT14  0:00 10000  04  10015  RVDRVA15      0:00     1:00

01OCT14  0:00 10000  02  10018  KCDRVA18      0:02     1:00

01OCT14  0:00 10000  05  10016  KCDRVA16      0:01     1:00

01OCT14  0:00 10000  00  10017  RVDRVA17      0:00     1:00

01OCT14  0:00 10000  03  1001A  KCDRVA1A      0:02     1:00

01OCT14  0:00 10000  01  10019  RVDRVA19      0:00     1:00

01OCT14  0:15 10000  04  10015  RVDRVA15      0:00     1:00

01OCT14  0:15 10000  02  10018  KCDRVA18      0:04     1:00

01OCT14  0:15 10000  05  10016  KCDRVA16      0:02     1:00

01OCT14  0:15 10000  00  10017  RVDRVA17      0:00     1:00

01OCT14  0:15 10000  03  1001A  KCDRVA1A      0:04     1:00

01OCT14  0:15 10000  01  10019  RVDRVA19      0:00     1:00

01OCT14  0:30 10000  04  10015  RVDRVA15      0:00     1:00

01OCT14  0:30 10000  02  10018  KCDRVA18      0:02     1:00

01OCT14  0:30 10000  05  10016  KCDRVA16      0:01     1:00

01OCT14  0:30 10000  00  10017  RVDRVA17      0:00     1:00

6 REPLIES 6
user24feb
Barite | Level 11

If it is just about the average: (?)

Proc Means Data=Your_Set NWay NoPrint;

  Class Date DistName;

  Var Var1;

  Output Out=Want (Drop=_:) Mean=;

Run;

rkumar23
Calcite | Level 5

It doesn't seems to bring write output....Do you know what should be the format for VAR1 while Reading? as if read with TIME. format that make output/average as 0:

  DAT      DISTNAME    DEFERR   

                                

01OCT14    KCDRVA1A       0     

01OCT14    KCDRVA16       0     

01OCT14    KCDRVA18       0     

01OCT14    RVDRVA15       0     

01OCT14    RVDRVA17       0     

01OCT14    RVDRVA19       0    

While reading VAR1 as numeric data bring missing value...

user24feb
Barite | Level 11

If you try this code?

rkumar23
Calcite | Level 5

Nope ..

DATE    DISTNAME    VAR1

                               

19997    KCDRVA1A       .      

19997    KCDRVA16       .      

19997    KCDRVA18       .      

19997    RVDRVA15       .      

19997    RVDRVA17       .      

19997    RVDRVA19       .     

user24feb
Barite | Level 11

Maybe the data-step works better (if it doesn't I'm out of luck; please make sure that the input-dataset is complete).

RW9
Diamond | Level 26 RW9
Diamond | Level 26

What is the format of VAR1, it looks like a time format?  If so then convert it to number.  Then you just need a sum of ROWS by DATE, and a count of ROWS by date:

data have;

  date="01OCT2014"d; var1="0:00"t; output;

  date="01OCT2014"d; var1="0:02"t; output;

  date="01OCT2014"d; var1="0:01"t; output;

  date="01OCT2014"d; var1="0:00"t; output;

  date="01OCT2014"d; var1="0:02"t; output;

run;

proc sql;

  create table WANT as

  select  distinct

          A.DATE format=date9.,

          B.ROW_SUM,

          C.CONVERTED / B.ROW_SUM as AV

  from    WORK.HAVE A

  left join (select distinct DATE,count(DATE) as ROW_SUM from WORK.HAVE group by DATE) B

  on      A.DATE=B.DATE

  left join (select DATE,sum(input(compress(tranwrd(put(VAR1,time5.),":","")),best.)) as CONVERTED from WORK.HAVE group by DATE) C

  on      A.DATE=C.DATE;

quit;

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!

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.

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
  • 6 replies
  • 1802 views
  • 0 likes
  • 3 in conversation