Hi! I'm trying to create a map using ZCTAs and then number of doctors in a zip code, but I'm having issues with import. This is my code for SAS 9.4:
/*Import ZCTA boundary file*/
Proc MAPIMPORT OUT=sczip
Datafile= "C:\tl_2010_45_zcta510\tl_2010_45_zcta510.shp";
run;
/* import excel file*/
PROC IMPORT OUT= WORK.zipsum
DATAFILE="C:\allzipsum.xlsx"
DBMS=xlsx replace;
GETNAMES=YES;
RUN;
/*change zipcode to character*/
data work.zipsum;
ZCTA5CE10= put(zipcode,5.);
run;
The ZCTA variable in the map data set is character and has the format and informat $5, and I have to match it.
SAS keeps telling me that zipcode is uninitialized. Then it deletes the other variable in the dataset.
I tried using DBDSOPTS, and SAS didn't recognize the command, so I'm at a loss of what to do next.
You don't have a SET statement and you shouldn't use the same data set name again, that will likely destroy your original data so you'll have to re-import it again.
data work.zipsum_with_zipCode;
set zipsum;
ZCTA5CE10= put(zipcode,5.);
run;
@jesspurse wrote:
Hi! I'm trying to create a map using ZCTAs and then number of doctors in a zip code, but I'm having issues with import. This is my code for SAS 9.4:
/*Import ZCTA boundary file*/ Proc MAPIMPORT OUT=sczip Datafile= "C:\tl_2010_45_zcta510\tl_2010_45_zcta510.shp"; run; /* import excel file*/ PROC IMPORT OUT= WORK.zipsum DATAFILE="C:\allzipsum.xlsx" DBMS=xlsx replace; GETNAMES=YES; RUN; /*change zipcode to character*/ data work.zipsum; ZCTA5CE10= put(zipcode,5.); run;
The ZCTA variable in the map data set is character and has the format and informat $5, and I have to match it.
SAS keeps telling me that zipcode is uninitialized. Then it deletes the other variable in the dataset.
I tried using DBDSOPTS, and SAS didn't recognize the command, so I'm at a loss of what to do next.
You don't have a SET statement and you shouldn't use the same data set name again, that will likely destroy your original data so you'll have to re-import it again.
data work.zipsum_with_zipCode;
set zipsum;
ZCTA5CE10= put(zipcode,5.);
run;
@jesspurse wrote:
Hi! I'm trying to create a map using ZCTAs and then number of doctors in a zip code, but I'm having issues with import. This is my code for SAS 9.4:
/*Import ZCTA boundary file*/ Proc MAPIMPORT OUT=sczip Datafile= "C:\tl_2010_45_zcta510\tl_2010_45_zcta510.shp"; run; /* import excel file*/ PROC IMPORT OUT= WORK.zipsum DATAFILE="C:\allzipsum.xlsx" DBMS=xlsx replace; GETNAMES=YES; RUN; /*change zipcode to character*/ data work.zipsum; ZCTA5CE10= put(zipcode,5.); run;
The ZCTA variable in the map data set is character and has the format and informat $5, and I have to match it.
SAS keeps telling me that zipcode is uninitialized. Then it deletes the other variable in the dataset.
I tried using DBDSOPTS, and SAS didn't recognize the command, so I'm at a loss of what to do next.
THANK YOU. That worked perfectly. I knew it was something simple I was missing; you spend so long staring at the code that it all blurs together.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.