This is a follow up to an problem I posted yesterday: https://communities.sas.com/t5/Base-SAS-Programming/Importing-dataset-with-dates-as-column-headers/m-p/334194#U334194 I have a .csv file with State, County, and population from 2000-2007. See attached sample. I was able to successfully load the file using proc import, however, I did not notice the population data loaded as character values. I started over and decided to import the file by copying and modifying code from the log; however, that's not working either. data WORK.POPULATION2001_2007 ; %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ infile 'C:\population_by_county_2001_2007.csv' delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ; informat State $25. ; informat County $30. ; informat _1_1_2001 best12. ; informat _1_1_2002 best12. ; informat _1_1_2003 best12. ; informat _1_1_2004 best12. ; informat _1_1_2005 best12. ; informat _1_1_2006 best12. ; informat _1_1_2007 best12. ; format State $25. ; format County $30. ; format _1_1_2001 comma12. ; format _1_1_2002 comma12. ; format _1_1_2003 comma12. ; format _1_1_2004 comma12. ; format _1_1_2005 comma12. ; format _1_1_2006 comma12. ; format _1_1_2007 comma12. ; input State $ County $ _1_1_2001 /*NOTE: I'll change the column header's later using a macro that was suggested in yesterday's post*/ _1_1_2002 _1_1_2003 _1_1_2004 _1_1_2005 _1_1_2006 _1_1_2007 ; if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */ run; Here's a sample of the error message I'm getting: NOTE: Invalid data for _1_1_2007 in line 20 95-100. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--- 20 Alabama,Coosa County,"11,746","11,539","11,423","11,156","10,964","10,857","10,783" 102 State=Alabama County=Coosa County _7_1_2001=. _7_1_2002=. _7_1_2003=. _7_1_2004=. _7_1_2005=. _7_1_2006=. _7_1_2007=. _ERROR_=1 _N_=19 For one thing, it appears my data still has quotes around it. I thought having DSD in the infile statement was supposed to help with issues such as these. Any thoughts on what I'm doing wrong? Also, is there a better way to change data from character to numeric? I am a student who is new to SAS, so while there might be something that's glaring obvious to most, it may not be to me -- at least not yet 😉
... View more