BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
venkatnaveen
Obsidian | Level 7

12/09/2010;Houston; TX; 77077

10/16/2009;Houston; TX; 77040

9/18/2009;Katy; TX; 77450

I have used the following:

data pd;

infile cards;

informat date mmddyy10.;

input date mmddyy10. address $12. area  $2. Pin ;

format date mmddyy10.;

cards4;      

12/09/2010;Houston; TX; 77077

10/16/2009;Houston; TX; 77040

9/18/2009;Katy; TX; 77450

;;;;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You should be able to add colon modifiers in front of the formats in your INPUT statement to prevent SAS from trying to read the delimiters between the fields as part of the values.

Personally I usually just use a list mode input INPUT statement when reading data in a list mode (lists delimited with semi-colons, tabs or commas are just like lists delimited with spaces).  Set the definitions of your variables with a LENGTH or ATTRIB statement instead of assuming SAS will figure it out from the format that you used on the INPUT statement.  If any fields require a special informat to be read properly then attach it to them with an INFORMAT or ATTRIB statement.

data pd;

  infile cards dlm= ';' dsd truncover;

  length date 8 address $12 area $2 Pin 8;

  informat date mmddyy10.;

  format date mmddyy10.;

  input date address area Pin ;

cards4;     

12/09/2010;Houston; TX; 77077

10/16/2009;Houston; TX; 77040

9/18/2009;Katy; TX; 77450

;;;;

View solution in original post

7 REPLIES 7
Peter_C
Rhodochrosite | Level 12

Try the following:

data pd;

infile cards dlm= ';' dsd;

informat date mmddyy10.;

input date  address :$12. area :  $2. Pin ;

format date mmddyy10.;

cards4;      

12/09/2010;Houston; TX; 77077

10/16/2009;Houston; TX; 77040

9/18/2009;Katy; TX; 77450

;;;;

venkatnaveen
Obsidian | Level 7

thanks peter

venkatnaveen
Obsidian | Level 7

Hi peter,

Thanks,

But,I am not getting result.

Ksharp
Super User

add   RUN;   at the end of code.

Peter_C
Rhodochrosite | Level 12

If you show us a saslog we might be able to help

Tom
Super User Tom
Super User

You should be able to add colon modifiers in front of the formats in your INPUT statement to prevent SAS from trying to read the delimiters between the fields as part of the values.

Personally I usually just use a list mode input INPUT statement when reading data in a list mode (lists delimited with semi-colons, tabs or commas are just like lists delimited with spaces).  Set the definitions of your variables with a LENGTH or ATTRIB statement instead of assuming SAS will figure it out from the format that you used on the INPUT statement.  If any fields require a special informat to be read properly then attach it to them with an INFORMAT or ATTRIB statement.

data pd;

  infile cards dlm= ';' dsd truncover;

  length date 8 address $12 area $2 Pin 8;

  informat date mmddyy10.;

  format date mmddyy10.;

  input date address area Pin ;

cards4;     

12/09/2010;Houston; TX; 77077

10/16/2009;Houston; TX; 77040

9/18/2009;Katy; TX; 77450

;;;;

venkatnaveen
Obsidian | Level 7

Thanks for talking time for resolving.

Thanks Tom.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 739 views
  • 0 likes
  • 4 in conversation