Hello team,
I have a dateTime as numeric as 06oct22:10:03, when I put datepart function to get the datepart of the variable, the time function still exists in the reuslt.
Date1 = put(datepart(date2,date9.)
Can someone help me with this?
Thanks,
blue blue
LOG. Read it.
If you actually submit that code you are missing a )
40 data example; 41 x='06oct22:10:03'dt; 42 y=put(datepart(x,date9.); ------ 386 76 ERROR 386-185: Expecting an arithmetic expression. ERROR 76-322: Syntax error, statement will be ignored. 43 run;
Should be:
44 data example; 45 x='06oct22:10:03'dt; 46 y=put(datepart(x),date9.); 47 run;
The result is 06OCT2022.
Or use a different FORMAT:
data example; x='06oct22:10:03'dt; y=put(x,dtdate9.); run;
The DTDATE format displays a datetime with just the DATE9 equivalent portion.
So if your code isn't working you either have an issue with the values, the syntax or possibly both.
Although I question a need for that creation of a character value for dates. They don't sort well, at least not in Date9 format, cause extra work if you need to compare to an actual date value elsewhere, cannot be used in any of the date functions like Intnx or Intck, use formats to modify group creation for analysis, reporting or graphing.
Show us the complete log of the step where this seems to happen.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: