how to view/print hhmmss into hh:mm format?

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

how to view/print hhmmss into hh:mm format?

how to view/print hhmmss into hh:mm format?

data test;

input edate $6. etime $6.;

datalines;

131025 083259

;

run;

proc print data= test;

run;

DATA ADHOC;

LENGTH EDATE $6. ETIME $6.;                            

SET test;                                             

FORMAT CHECKDATE DDMMYY10.;

FORMAT CHECKTIME TIME8.; 

YEAR = SUBSTR(EDATE,1,2);                                    

MONTH= SUBSTR(EDATE,3,2);                                    

DATE = SUBSTR(EDATE,5,2);                                    

TEMPDATE = PUT(DATE,$2.)!!PUT(MONTH,$2.)!!PUT(YEAR,$2.);     

CHECKDATE= INPUT(TEMPDATE,DDMMYY10.);                                                             

HOUR = SUBSTR(ETIME,1,2);                                    

MINUTE=SUBSTR(ETIME,3,2);                                       

SECOND=SUBSTR(ETIME,5,2);                                       

TEMPTIME = PUT(HOUR,$2.)!!PUT(MINUTE,$2.)!!PUT(SECOND,$2.);     

CHECKTIME= INPUT(TEMPTIME,TIME8.);                              

run;

Please verify

Attachment

Accepted Solutions
Solution
‎11-11-2013 06:00 AM
New Contributor
Posts: 2

Re: how to view/print hhmmss into hh:mm format?

data test;

input edate $6. etime $6.;

datalines;

131025 083259

;

run;

proc print data= test;

run;

DATA ADHOC;

LENGTH EDATE $6. ETIME $6.;                            

SET test;                                             

YEAR = SUBSTR(EDATE,1,2);                                    

MONTH= SUBSTR(EDATE,3,2);                                    

DATE = SUBSTR(EDATE,5,2);                                 

HOUR = SUBSTR(ETIME,1,2);                                    

MINUTE=SUBSTR(ETIME,3,2);                                       

SECOND=SUBSTR(ETIME,5,2);                                        

tt_dtdm=PUT(DATE,$2.)!!'/'!!PUT(MONTH,$2.)!!'/'!!PUT(YEAR,$2.)!!' '!!PUT(HOUR,$2.)!!':'!!PUT(MINUTE,$2.)!!':'!!PUT(SECOND,$2.);

run;

proc print data=  ADHOC;

run;

Got it

View solution in original post


All Replies
Solution
‎11-11-2013 06:00 AM
New Contributor
Posts: 2

Re: how to view/print hhmmss into hh:mm format?

data test;

input edate $6. etime $6.;

datalines;

131025 083259

;

run;

proc print data= test;

run;

DATA ADHOC;

LENGTH EDATE $6. ETIME $6.;                            

SET test;                                             

YEAR = SUBSTR(EDATE,1,2);                                    

MONTH= SUBSTR(EDATE,3,2);                                    

DATE = SUBSTR(EDATE,5,2);                                 

HOUR = SUBSTR(ETIME,1,2);                                    

MINUTE=SUBSTR(ETIME,3,2);                                       

SECOND=SUBSTR(ETIME,5,2);                                        

tt_dtdm=PUT(DATE,$2.)!!'/'!!PUT(MONTH,$2.)!!'/'!!PUT(YEAR,$2.)!!' '!!PUT(HOUR,$2.)!!':'!!PUT(MINUTE,$2.)!!':'!!PUT(SECOND,$2.);

run;

proc print data=  ADHOC;

run;

Got it

🔒 This topic is solved and locked.

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

Discussion stats
  • 1 reply
  • 186 views
  • 0 likes
  • 1 in conversation