Good afternoon,
I have a column within my dataset called "file_accepted". A sample record shows as "09MAR2007:16:12:21".
I am trying to create a field that grabs the 2 digits after the first colon, in this example the 16... which is military time for 4pm. Ideally, I would like my new field to be coded as "1" if the time is at 4PM or after, and "0" if the time is before 4PM.
Thank you!
What type of variable, character or numeric? If the variable is a SAS datetime value, numeric with a format of DATETIME18 or similar then you can check the Hour of the value with the hour function:
data want;
set have;
newvar = (Hour(file_accepted) ge 16);
run;
If it isn't a datetime value then you really should make a datetime valued version as most of the steps involving comparisons, selections or other manipulations of datetimes start with that conversion.
What type of variable, character or numeric? If the variable is a SAS datetime value, numeric with a format of DATETIME18 or similar then you can check the Hour of the value with the hour function:
data want;
set have;
newvar = (Hour(file_accepted) ge 16);
run;
If it isn't a datetime value then you really should make a datetime valued version as most of the steps involving comparisons, selections or other manipulations of datetimes start with that conversion.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.