Hello, I have the date below coming up as "char" , 15, $15, $15 but I want it to be "num", 8, Datetime , anydtdtm40.
Obs | BP_Rd_Time |
---|---|
1 | |
2 | 2/9/2017 13:44 |
3 | |
4 | 2/8/2017 13:20 |
5 | |
6 | 2/8/2017 14:45 |
7 | |
8 | 2/8/2017 8:00 |
9 | 2/16/2017 19:31 |
10 | |
11 | |
12 | |
13 | 2/21/2017 2:45 |
14 | 2/6/2017 22:15 |
15 |
If these are truly character and not numeric, you can turn them into numerics via the INPUT function, using one of these informats: ANYDTDTEw. ANYDTDTMw. ANYDTTMEw.
If these are truly character and not numeric, you can turn them into numerics via the INPUT function, using one of these informats: ANYDTDTEw. ANYDTDTMw. ANYDTTMEw.
I do not understand.
1573 data firstobs;
1574 set firstobs;
1575 BP_Time=input(BP_Rd_Time, ANYDTDTEw.);
----------
48
ERROR 48-59: The informat ANYDTDTEW was not found or could not be loaded.
1576 run;
NOTE: Numeric values have been converted to character values at the places given by:
(Line):(Column).
1575:9 1575:15
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.FIRSTOBS may be incomplete. When this step was stopped there were
0 observations and 64 variables.
WARNING: Data set WORK.FIRSTOBS was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
See the approach outlined here:
https://communities.sas.com/t5/Base-SAS-Programming/date-manupulation/m-p/383548
It's a variant on the same question where you need to convert a character to a date format.
If you can't get it working, post your code and we're happy to help.
@desireatem wrote:
I do not understand.
1573 data firstobs;
1574 set firstobs;
1575 BP_Time=input(BP_Rd_Time, ANYDTDTEw.);
----------
48
ERROR 48-59: The informat ANYDTDTEW was not found or could not be loaded.1576 run;
NOTE: Numeric values have been converted to character values at the places given by:
(Line):(Column).
1575:9 1575:15
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.FIRSTOBS may be incomplete. When this step was stopped there were
0 observations and 64 variables.
WARNING: Data set WORK.FIRSTOBS was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
Don't code like this, having the same name in your DATA and SET statement. Look slightly further down and notice the warning. You've now destroyed your input data set and now need to recreate it.
1573 data firstobs;
1574 set firstobs;
...
WARNING: The data set WORK.FIRSTOBS may be incomplete. When this step was stopped there were
0 observations and 64 variables.
EDIT: w in the informat is for the width, the docs show it as a number. Either remove it or add a number in its place to indicate the width of the informat.
Same error message;
1581 data firstobs10;
1582 set firstobs;
1583 BP_Time=input(BP_Rd_Time, ANYDTDTEw.);
----------
48
ERROR 48-59: The informat ANYDTDTEW was not found or could not be loaded.
1584 run;
NOTE: Numeric values have been converted to character values at the places given by:
(Line):(Column).
1583:9 1583:15
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.FIRSTOBS10 may be incomplete. When this step was stopped there
were 0 observations and 64 variables.
WARNING: Data set WORK.FIRSTOBS10 was not replaced because this step was stopped.
The lowercase w is just used as a placeholder for the length of the informat.
Thanks, this is correct:
data firstobs10;
set firstobs2;
BP_Time=input(BP_Rd_Time, ANYDTDTM40.);
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.