BookmarkSubscribeRSS Feed
Arpit2
Calcite | Level 5

i got stuck in this problem and it is not showing sas format  date value .

data out;
input CALL_NO 1-3
 DATE 5-12
TRUCKS 14-15
ALARM 17;
informat date mmddyy8.;
datalines;
001 10/21/94 03 2
002 10/23/94 01 1
003 11/01/94 11 3
;
run;

 

4 REPLIES 4
novinosrin
Tourmaline | Level 20

data out;
input CALL_NO 1-3
 @5 DATE mmddyy8.
TRUCKS 14-15
ALARM 17;
format date mmddyy8.;
datalines;
001 10/21/94 03 2
002 10/23/94 01 1
003 11/01/94 11 3
;
run;
Reeza
Super User
INFORMATS are the input format, what a variable currently looks like.
FORMATS control the display of the output data.

You will not "see" an informat, but your data will be read in correctly. Try adding a FORMAT statement and you should get what you need.

FreelanceReinh
Jade | Level 19

Hi @Arpit2 and welcome to the SAS Support Communities!

 

The documentation "INPUT Statement: Column" says: "To read with column input, data values must ... consist of standard numeric form or character form." So, date values in the form "mm/dd/yy" preclude column input. Just switch to list input by deleting the column specifications (1-3, ..., 17) in your DATA step. The suggested FORMAT statement is useful for displaying the date values, but not necessary for reading the raw data.

Tom
Super User Tom
Super User

You cannot use column mode input statement and an INFORMAT.  You will need to either read the value as character and use INPUT() function to generate the date value. Or read at least that one field using formatted mode input instead.

data out;
  input
    CALL_NO 1-3
    @5 DATE mmddyy8.
    TRUCKS 14-15
    ALARM 17
  ;
  format date mmddyy10.;
datalines;
001 10/21/94 03 2
002 10/23/94 01 1
003 11/01/94 11 3
;

Or if you are positive that every variable has a value (or when missing a period) then use list mode input.  In that case you can either use the INFORMAT statement to set the informat for the variable or include the informat in the input statement but add the : modifier so that it still does list mode input.

data out;
  input
    CALL_NO
    DATE :mmddyy8.
    TRUCKS 
    ALARM 
  ;
  format date mmddyy10.;
datalines;
001 10/21/94 03 2
002 10/23/94 01 1
003 11/01/94 11 3
;

PS  Do NOT use only two digits for year values.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 466 views
  • 0 likes
  • 5 in conversation