DATA Step, Macro, Functions and more

Date showing as numeric at input

Reply
Regular Contributor
Posts: 180

Date showing as numeric at input

%LET inputlist= INPUT

 

State : $CHAR2.

Servicer : $CHAR25.

Date : /*$CHAR10.

The above is a snippet of code.  It handles input from a share folder in which the date is inputted as a numeric.  However because it is not recognized as an actual date the field shows a blank for that value.  The only way I know around this is to read it in as a character then attempt to convert to a date.  Is there a way to convert this to a date at initial input instead?  I tried placing an 8. after Date: 8. however that does not show the date

Super User
Posts: 4,026

Re: Date showing as numeric at input

We can't help unless you post what your date input data looks like and the actual full code that is reading it.

Super User
Posts: 13,941

Re: Date showing as numeric at input


Q1983 wrote:

%LET inputlist= INPUT

 

State : $CHAR2.

Servicer : $CHAR25.

Date : /*$CHAR10.

The above is a snippet of code.  It handles input from a share folder in which the date is inputted as a numeric.  However because it is not recognized as an actual date the field shows a blank for that value.  The only way I know around this is to read it in as a character then attempt to convert to a date.  Is there a way to convert this to a date at initial input instead?  I tried placing an 8. after Date: 8. however that does not show the date


Depending on your source file format, practically anything not binary such as txt or CSV or tab delimited or fixed column, should not have a problem reading values using a format if you know which variable and which the format should be.

It might be as simple as using an INFORMAT statement before the input. It is a good idea to assign a display format as well so you aren't asking is 21347 the right value.

 

informat datevar date9. ;

format datevar date9.;

input <variables>      datevar  <more variables>;

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