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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2081 views
  • 0 likes
  • 4 in conversation