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
;;;;
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
;;;;
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
;;;;
thanks peter
Hi peter,
Thanks,
But,I am not getting result.
add RUN; at the end of code.
If you show us a saslog we might be able to help
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
;;;;
Thanks for talking time for resolving.
Thanks Tom.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.