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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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