- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-17-2019 10:51 PM
(9745 views)
Data have character time
time
10:32
10:14
10:15
10:06
09:42
i want
10:32:00
10:14:00
10:15:00
10:06:00
09:42:00
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You would read a raw file (i.e. a text file with character values for time) with an INPUT statement, and a suitable INFORMAT for the variable. Analogously you can read a character variable to a numeric (time) variables with an INPUT function, and a suitable INFORMAT.
data have;
input txt_time $5.;
datalines;
10:32
10:14
10:15
10:06
09:42
run;
data want;
set have;
num_time=input(txt_time,time5.0);
format num_time time8.0;
put num_time=;
run;
whilch display on the log
num_time=10:32:00
num_time=10:14:00
num_time=10:15:00
num_time=10:06:00
num_time=9:42:00
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Found it helpful!
Dr. Abhijeet Safai
Certified Base and Clinical SAS Programmer
Associate Data Analyst
Actu-Real
Certified Base and Clinical SAS Programmer
Associate Data Analyst
Actu-Real
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data have;
input time $10.;
cards;
10:32
10:14
10:15
10:06
09:42
;
data want;
set have;
num_time=input(time,time.);
format num_time time8.;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You fix that when you read the data in the first place:
data have;
input time time5.;
format time time8.;
cards;
10:32
10:14
10:15
10:06
09:42
;