Dates coming in as char

Reply
Contributor
Posts: 20

Dates coming in as char

I have dates coming in at $10. listed as 2013-10-06.  I need to make them numeric 8.  I have tried several things - this is the last srv_start_dt1 = input(srv_start_dt,yymmdd10.);  Not sure what I am missing?  Thank you

Contributor
Posts: 74

Re: Dates coming in as char

Hi,

I don't see what the problem is.  You are converting it to numeric and getting the right value. Maybe I'm misunderstanding the question...?

data a;

    srv_start_dt = '2013-10-06';

    srv_start_dt1 = input(srv_start_dt,yymmdd10.); 

    put srv_start_dt1 =;

    put srv_start_dt1= date9.;

run;

proc contents; run;

Valued Guide
Posts: 858

Re: Dates coming in as char

If you want the field to be formatted as a date you should specify date, not number.  Run this and look at the formatting for the three fields, you'll see three different fields, date, char and num:

data have;

infile cards dsd;

length char_date $10.;

input char_date;

cards;

2013-10-06

;

data date;

format date_date yymmddn8.;

set have;

date_date = input(put(char_date,$10.),yymmddn10.);

run;

data num;

set want;

num_date = input(put(date_date,yymmddn8.),8.);

run;

Ask a Question
Discussion stats
  • 2 replies
  • 167 views
  • 0 likes
  • 3 in conversation