formatting date variable doesn't work

Multi tool use
formatting date variable doesn't work
I am doing data step using the following code.
data meme;
infile '/home/bronx.txt' dlm='09'x truncover firstobs=2;
length ADDRESS $12. DATE 8. GROSS 5. LAND 8. SALE 6. YEAR 4. ZIP 6.;
format DATE mmddyy10.;
input ADDRESS $ ZIP LAND GROSS YEAR SALE DATE;
run;
Nonetheless, this error always accures:
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
1 Answer
1
Looks like you do not understand what SAS formats and informats are for.
A FORMAT is instructions for converting the stored value into text. To go the otther way you need to use an INFORMAT. So if the text in your file looks like 01/01/2016
then you would want to use the MMDDYY
informat (or perhaps the DDMMYY
informat). If it looks like 01JAN2016
then you will want to use the DATE
informat. If you want to value to look like dates when printed then you should also apply one of the many date formats.
01/01/2016
MMDDYY
DDMMYY
01JAN2016
DATE
It also looks like you do not understand how the LENGTH
statement works. In a LENGTH
statement you need to specify the lengths for the variable, not formats. The LENGTH of a SAS variable is the number of bytes used to store the value in the dataset. Since SAS uses 64-bit floating point format for all numbers you should use a length of 8 for numbers. (You can store numbers using fewer bytes but that just means SAS throws away the lower order bytes when writing to the dataset.)
LENGTH
LENGTH
You might try something more like this:
data meme;
infile '/home/bronx.txt' dlm='09'x truncover firstobs=2;
length ADDRESS $12 ZIP LAND GROSS YEAR SALE DATE 8;
format DATE mmddyy10.;
informat DATE mmddyy.;
input ADDRESS ZIP LAND GROSS YEAR SALE DATE;
run;
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.