I have a question. I have a field in my SAS dataset that has a mixture of datetime and date variables.
The field is PST_DT and is Type: Numeric. Group: Date. Format: Date9. Length: 8.
Some values look like this:
Removed
How can I turn just the datetime values in date format? I want all the values to be in date format.
Thanks.
This does not look like a date9 formatted variable. Can you show a PROC CONTENTS output?
Removed
Then your original example CAN NOT be from this dataset. Your date values would both(!) display as 22AUG2018, without ANY time value.
@user112a2 wrote:
@user112a2 wrote:
I have a question. I have a field in my SAS dataset that has a mixture of datetime and date variables.
The field is PST_DT and is Type: Numeric. Group: Date. Format: Date9. Length: 8.
Some values look like this:PST_DT 8/22/2018 11:59:59 PM 8/22/2018How can I turn just the datetime values in date format? I want all the values to be in date format.
Thanks.
There's nothing at all that looks like a date9 formatted value.
Is your example actually a part of a text file you want to read into a SAS dataset?
These values were imported from an excel file into SAS. Some of the values had dates and some had datetime values. These were imported into a SAS data set.
Then please post the values as they are in the dataset. A date9. formatted variable can NEVER look like 8/22/2018. NEVER.
This worked!!!!
Removed
@user112a2 wrote:
This worked!!!!
data OUT.REQ_1_3_02 ; SET OUT.REQ_1_3_01; a= day(PST_DT); b= month(PST_DT); c= year(PST_DT); date = input(catx("/",b,a,c),mmddyy10.); format date mmddyy10.; run ;
Under normal circumstances, if PST_DT contains valid SAS date values or ordinary missing values, the four highlighted lines above could be simplified to:
date=PST_DT;
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.