01-02-2013 07:26 AM
My name is woo.
and I'm having problem with my research so I need some tips from SAS professional who are familliar with this problem.
I really want to measure exact time of Wifi Use.
And data is as follows...
Connected 0 represents Wifi is disconnected
and 1 represents Wifi is connected
At first, I thought it was very easy and I wrote some code like this;
INFILE "D:\research\Wifi_Status_august.csv" dlm="," LRECL=300 TRUNCOVER firstobs=2;
INPUT UserId :$20. Clientkey :$1. Time :anydtdtm19. Connected IsOpen ;
keep Userid Time Connected;
Proc sort data=Wifi_status; by userid time; run;
set Wifi_status; if connected=1;
keep userid Starttime
proc sort data=Wifi_status1; by userid Starttime; run;
set Wifi_status; if connected=0;
keep userid Endtime
proc sort data=Wifi_status2; by userid Endtime; run;
merge Wifi_status1 Wifi_status2;
But, there's some mistakes or erros in the data like sequencing 0000 or 111.
So, My result is totally crabbed..
I want to leave out some faults in my data How can I leave them out?
Please give me some your generous tips.
01-02-2013 09:22 AM
Some sample data to work with would help,
but I would first suggest that instead of taking the variable "TIME" as is, I would first strip the date out of the "TIME" variable, thus obtaining the hour and minutes.
So, say, you have time = 2012-08-01 8:49, what you really want is a way to strip the time from the date.
you need to also keep a count for the date (so if one is connected for 2 days and four hours, you actually count the days as well).
Please provide some sample data.
01-02-2013 10:57 AM
After your sort I would try
proc means data=WiFi_status;
by connected notsorted;
output out=usertime max= min= range=/autoname;
The output dataset should have a record for each contiguous period of time connected and not connected. The range is what you want but the units aren't going to be obvious, the max and min will show per period as well.
01-02-2013 08:45 PM
You can use the DAY function from SAS.
day_part = day(time_variable);
You could attach a sample data (say 10 observations max, and make sure you de-identify the data)