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
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
I might have gotten it I did a datepart and added date I then group it by site id. Machine. Date.
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.
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.