I have below macro variable
%let x=2019-10-31 00:00:00.447000;
This macro variable is having a value as character .i want it to convert to numeric 26
How can i do that ?
Hi @shubham1 ,
Something like this?
%let x= %sysfunc(inputn(2019-10-31 00:00:00.447000, ymddttm24.));
%put &x;
Result: 1888099200.447
Hi @shubham1 ,
Something like this?
%let x= %sysfunc(inputn(2019-10-31 00:00:00.447000, ymddttm24.));
%put &x;
Result: 1888099200.447
I think output is wrong
it is not coming as 2019-10-31 00:00:00.447000 .I want value to be numeric as 2019-10-31 00:00:00.447000
Hi @shubham1
Macro variables are strings. They have no type (numeric / character).
All datetimes values are stored as numbers by SAS. If you want to use them for further calculation, you need to get those numbers.
2019-10-31 00:00:00.447000
is not a valid numeric value.
@shubham1 wrote:
I think output is wrong
it is not coming as
2019-10-31 00:00:00.447000 .I want value to be numeric as 2019-10-31 00:00:00.447000
The result from @ed_sas_member of 1888099200.447 is correct. SAS considers date/times to be the number of seconds since midnight January 1, 1960, so that is how your date/time is represented in SAS. You can optionally format it so that it looks like an actual date/time to humans when they see it, but internally it needs to be 1888099200.447. You need to adjust your thinking so that you can use date/times properly in SAS. Any comparison of date/time values must be done numerically, rather than by a text string.
there was something wrong I did at my end sorry for that your solution is working
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.