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

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