BookmarkSubscribeRSS Feed
Yondori
Calcite | Level 5

Hi

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

prob1.png

At first, I thought it was very easy and I wrote some code like this;

DATA Wifi_status;

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;

run;

Proc sort data=Wifi_status; by userid time; run;

data Wifi_status1;

set Wifi_status; if connected=1;

Starttime=Time;

connected1=connected;

keep userid Starttime
connected1;
run;

proc sort data=Wifi_status1; by userid Starttime; run;

data Wifi_status2;

set Wifi_status; if connected=0;

Endtime=Time;

connected0=connected;

keep userid Endtime
connected0;
run;

proc sort data=Wifi_status2; by userid Endtime; run;

Data Wifi_status0;

merge Wifi_status1 Wifi_status2;

Wifi_sec=endtime-starttime;

Wifi_min=(Wifi_sec)/60;

run;

But, there's some mistakes or erros in the data like sequencing 0000 or 111.

So, My result is totally crabbed..

like this

pro2.png

I want to leave out some faults in my data How can I leave them out?

Please give me some your generous tips.

Thanks

5 REPLIES 5
AncaTilea
Pyrite | Level 9

Hi.

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.

BUT

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.

Thanks.

Yondori
Calcite | Level 5

Thanks for your advice.

But, How can I extract the days from My 'Time' Variable..

ps. I can email you sample file

ballardw
Super User

After your sort I would try

proc means data=WiFi_status;

     class userid;

     by connected notsorted;

     var time;

     output out=usertime max= min= range=/autoname;

run;

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.

Yondori
Calcite | Level 5

Well;

I followed your code and SAS told me "Warning : Obsessive Print Size! "

Thanks for the advice but, it won't work

AncaTilea
Pyrite | Level 9

Hi.

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)

Good luck.

sas-innovate-2024.png

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.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1417 views
  • 0 likes
  • 3 in conversation