DATA Step, Macro, Functions and more

infile comma delimiter embedded blanks missing values

Accepted Solution Solved
Reply
Contributor
Posts: 32
Accepted Solution

infile comma delimiter embedded blanks missing values

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

 

Have to read this in with infile cannot get the right combination of options to deal with missing values, comma delimited, embedded blanks for name, length statement or informat for name .  Tried as many combinations as I could come up with. here is most recent attempt.


DATA Pumkins2;
infile pumpkins DLM= ',';
input Name & $16. Age 2. Type $ EnterDate mmddyy10. j1-j5;
format EnterDate mmddyy10.;
RUN;
PROC PRINT;
RUN;
title;


Accepted Solutions
Solution
‎03-19-2018 06:19 PM
Super User
Posts: 6,534

Re: infile comma delimiter embedded blanks missing values

When using delimiters, such as commas, don't try to give SAS instructions about how many characters to read.  Instead, set a maximum length and let SAS figure out which characters to read.  For example:

 

data test;

infile pumpkins dsd;

length name $ 16;

informat EnterDate mmddyy10.;

input Name Age Type $ EnterDate j1-j5;

format EnterDate mmddyy10.;

run;

View solution in original post


All Replies
Solution
‎03-19-2018 06:19 PM
Super User
Posts: 6,534

Re: infile comma delimiter embedded blanks missing values

When using delimiters, such as commas, don't try to give SAS instructions about how many characters to read.  Instead, set a maximum length and let SAS figure out which characters to read.  For example:

 

data test;

infile pumpkins dsd;

length name $ 16;

informat EnterDate mmddyy10.;

input Name Age Type $ EnterDate j1-j5;

format EnterDate mmddyy10.;

run;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 87 views
  • 0 likes
  • 2 in conversation