BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
desireatem
Pyrite | Level 9

 

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  
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
desireatem
Pyrite | Level 9

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

Reeza
Super User

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


 

Reeza
Super User

 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.

desireatem
Pyrite | Level 9

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.

desireatem
Pyrite | Level 9

Thanks, this is correct:

 

data firstobs10;
set firstobs2;
BP_Time=input(BP_Rd_Time, ANYDTDTM40.);
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 941 views
  • 0 likes
  • 4 in conversation