SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Handling missing time varaible

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

Handling missing time varaible

hello,

 

i have two variables in my data set date and time(HH:MM) in seperate columns, i need to combine those columns and sort the data by  date and time per subject.

 

While doing so i came across the situation like, the time is missing for one of the subjects ,and when i sort the data ,the record with missing time sorted to the top which leads to incorrect sorted data.

 

Kindly help me with this and handle the situation

 

Thank you


Accepted Solutions
Solution
‎07-15-2018 02:05 PM
Respected Advisor
Posts: 3,294

Re: Handling missing time varaible

Here is one solution

 

UNTESTED CODE

 

data want;
    set have;
    if not missing(time) then datetime=dhms(date,hour(time),minute(time),0);
    else datetime=dhms(date,0,0,0);
run;
proc sort data=have;
    by datetime;
run;

Naturally, there are other solutions regarding what to do with the missing time variable, I'm sure you can think of other ways to handle this.

--
Paige Miller

View solution in original post


All Replies
Solution
‎07-15-2018 02:05 PM
Respected Advisor
Posts: 3,294

Re: Handling missing time varaible

Here is one solution

 

UNTESTED CODE

 

data want;
    set have;
    if not missing(time) then datetime=dhms(date,hour(time),minute(time),0);
    else datetime=dhms(date,0,0,0);
run;
proc sort data=have;
    by datetime;
run;

Naturally, there are other solutions regarding what to do with the missing time variable, I'm sure you can think of other ways to handle this.

--
Paige Miller
Contributor
Posts: 21

Re: Handling missing time varaible

Posted in reply to PaigeMiller

thank you so much paige 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 106 views
  • 0 likes
  • 2 in conversation