BookmarkSubscribeRSS Feed
Saurav
Fluorite | Level 6

dm"log;clear;output;clear";
DATA pumpkins1;
infile datalines dlm="," dsd;
length name $16 ;
input name $ age type $ EnterDate mmddyy10. (j1-j5);
DATALINES;
Alicia Grossman,13,C,10-28-2008,7.8,6.5,7.2,8.0,7.9
Matthew Lee,9,D,10-30-2008,6.5,5.9,6.8,6.0,8.1
Elizabeth Garcia,10,C,10-29-2008,8.9,7.9,8.5,9.0,
,6,D,10-30-2008,6.7,5.6,4.9,5.2,6.1
Jose Martinez,7,D,10-31-2008,8.9,,10.0,9.7,9.0
Brian Williams,11,C,10-29-2008,7.8,8.4,8.5,7.9,8.0
;
RUN;
PROC PRINT data = pumpkins1;
format Enterdate mmddyy10.;
RUN;

 

my output is attached


j1_not_printing.JPG
7 REPLIES 7
Astounding
PROC Star

Because the date variable is read using formatted input (not list input), the input pointer stops before the comma that follows the date.

 

The software starts looking for J1, and then hits the comma so J1 is missing.  (Notice how the remaining variables J2-J5 are reading the values that you actually intended for J1-J4.)

 

An easy fix:  change the INPUT statement to move past that comma:


input name $ age type $ EnterDate mmddyy10. +1 (j1-j5);

 

That's untested code, but should resolve the problem.

Shmuel
Garnet | Level 18

I cann't explain why but I changed the INFILE statment and the INPUTstatement, until it worked fine:

 

INFILE DATALINES DLM=","  TRUNCOVER;

input name $ age type $ EnterDate mmddyy10. j1-j5;

 

PGStats
Opal | Level 21

Should be:

 

DATA pumpkins1;
infile datalines dsd; /* dsd implies dlm="," */
length name $16 ;
input name $ age type $ EnterDate :mmddyy10. j1-j5; /* Check list input in the doc */
DATALINES;
Alicia Grossman,13,C,10-28-2008,7.8,6.5,7.2,8.0,7.9
Matthew Lee,9,D,10-30-2008,6.5,5.9,6.8,6.0,8.1
Elizabeth Garcia,10,C,10-29-2008,8.9,7.9,8.5,9.0,
,6,D,10-30-2008,6.7,5.6,4.9,5.2,6.1
Jose Martinez,7,D,10-31-2008,8.9,,10.0,9.7,9.0
Brian Williams,11,C,10-29-2008,7.8,8.4,8.5,7.9,8.0
;
/* run; Not required after datalines; */

PROC PRINT data = pumpkins1;
format Enterdate mmddyy10.;
RUN;
PG
Saurav
Fluorite | Level 6
EnterDate :mmddyy10. why (:) is necessay in input ? is this due to informat and non-standard data.

when do we use colon?
Rick_SAS
SAS Super FREQ

Great question. You can either use an INFORMAT statement or use an informat modifier (:).

 

informat EnterDate mmddyy10.;

input name $ age type $ EnterDate j1-j5;

 

-OR-

input name $ age type $ EnterDate : mmddyy10. j1-j5;

 

 

 

Saurav
Fluorite | Level 6
Thanks for answering specifically input.

Why (:) is necessary in EnterDate : mmddyy10.

can't EnterDate mmddyy10. work in input?
Rick_SAS
SAS Super FREQ

Please read the link the documentation that i provided.

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
  • 1773 views
  • 2 likes
  • 5 in conversation