BookmarkSubscribeRSS Feed
BETO
Fluorite | Level 6

i have a data step that  groups by site I need to group by date as well. Currently it looks like this 

 

site id.       Machine                            Machine                                                     Machine

123.       04nov2015 09:39:12         04nov2015p 09:39:12                            23nov2015 09:39:12

 

i need to only see 11/04/15  one day than on its own row

siteid.  Machine

123.      23nov2015 09:39:12

 

my code is 

data report6 (drop=I n Mac  st et  dh) ;

retain siteid total machine1 starttime1 endtime1 dur_time1 &allvar. n;

format &mac. $10 &st . &et. Date time.;

set want3(rename =(machine2=Mac starttime2=st endtime2=et durtime2=dh();

by site_id machine1;

 

Array m(*) &Mac.;

array s(*) &st.;

Array e(*)&et.;

array d(*)&dh.;

if first .site Id  Or first.machine then 

do ; n=0;

do i=1 to &mx;

m(I) ="";s(I)=.;e(I)=.;d(I)=.;

end;

 

n+1;

m(n)=Mac;

s(n)=st;

e(n)=et;

d(n)=dh;

if last.siteid or last.machine1 then output report6;

run;

 

thanks for the assistance 

2 REPLIES 2
Reeza
Super User

It looks like a wide to long transpose, there are two common ways - one is with an array and the second is with a transpose. 

 

If you're looking for the latest date you could use the max function to find the maximum date. 

 

Here are two write ups on how to transpose your data.

 

http://www.ats.ucla.edu/stat/sas/modules/wtol_transpose.htm

http://www.ats.ucla.edu/stat/sas/modules/widetolong_data.htm

BETO
Fluorite | Level 6

I might have gotten it I did a datepart and added date  I then group it by site id. Machine. Date.  

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
  • 2 replies
  • 758 views
  • 0 likes
  • 2 in conversation