DATA Step, Macro, Functions and more

Changing date value from dd/mm/yyyy

Reply
N/A
Posts: 0

Changing date value from dd/mm/yyyy

Hi All

I am having come issues changing the date format from dd/mm/yyyy to yyyymmdd.

Everything i do I get
ERROR 48-59: The format $YYMMDD was not found or could not be loaded.

Here is my SAS program which is run on the mainframe:

OPTIONS ERRORABEND;

DATA ONE;
LENGTH INVDATEL $10.;
LENGTH INV_NO $06.;
LENGTH NETDUEDATE $10.;

INFILE DMINPUT DELIMITER = ',' MISSOVER;


INPUT
INV_HEADER_TYPE $
NETDUEDATE $
INV_NO $
;
CURRENTDATE = DATE();
NETDUEDATE2=PUT(NETDUEDATE,YYMMDD6.);

DATA SENDIT;
SET ONE;
FILE DMOUTPT;
PUT @029 NETDUEDATE2 YYMMDD6.
;

Thanks for your help
Super Contributor
Super Contributor
Posts: 3,174

Re: Changing date value from dd/mm/yyyy

You are attempting to use a PUT where you need to be using an INPUT. The code you have shared is reading up your "date-string" as character with the specified INFORMAT in your INPUT statement.

To convert that character string to a SAS numeric DATE variable, you need to use the INPUT function with the specific INFORMAT based on the string.

Also, with your INFILE statement, you may want to explore whether or not the DSD parameter may be needed, if you might have null input fields to read up.

Scott Barry
SBBWorks, Inc.


Step-by-Step Programming with Base SAS Software, Working with Dates in the SAS System
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304321.htm

SAS Language Reference: Dictionary, Informats
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000309877.htm
Ask a Question
Discussion stats
  • 1 reply
  • 165 views
  • 0 likes
  • 2 in conversation