BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jesspurse
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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.


 

View solution in original post

2 REPLIES 2
Reeza
Super User

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.


 

jesspurse
Obsidian | Level 7

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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 2 replies
  • 780 views
  • 0 likes
  • 2 in conversation