Running this code :
data electric.blt_hours;
set electric.blt;
Hours = hour(TransDateTime) ;
run;
Here is the property of the datetime field that was read in using proc import with guessing rows option.
Log states:
Your dataset has only one observation, and in this one observation the variable in question contains a missing value. From a missing value, only a missing value can result.
@programeerSAS wrote:
Running this code :
data electric.blt_hours;
set electric.blt;Hours = hour(TransDateTime) ;
run;
Here is the property of the datetime field that was read in using proc import with guessing rows option.
Log states:
NOTE: Missing values were generated as a result of performing an operation on missing values.Each place is given by: (Number of times) at (Line):(Column).1 at 72:9NOTE: There were 1 observations read from the data set ELECTRIC.BLT.NOTE: The data set ELECTRIC.BLT_HOURS has 1 observations and 4 variables.Not sure why the hour cannot be read if it is a numeric SAS date value it is reading from....
PS from a valid datetime value, the HOUR function returns the hour as documented:
data _null_;
now = datetime();
hours = hour(now);
format now e8601dt19.;
put now= hours=;
run;
Log:
69 data _null_; 70 now = datetime(); 71 hours = hour(now); 72 format now e8601dt19.; 73 put now= hours=; 74 run; now=2022-04-29T12:18:40 hours=12
@programeerSAS wrote:
Hi Kurt
My blt dataset has many rows of data in it.
Your log says something completely different. I believe SAS in this.
Can you provide few rows of your data?
Hi Kurt - you were spot on!
I had the table open but a piece of my code messed up the dataset. I re-imported, ran the code as is and voila!
Thank you!
Please provide the ENTIRE log for this DATA step, instead of what you did was just show us pieces of the log. Please copy the log as text and then click on the </> and paste the log into the window that appears.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.