As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Fixed Zipstate function

From sasCommunity
Jump to: navigation, search

I got tired of my SAS log being filled with error notes when using the Zipstate function to convert zip codes in my source data to postal state abbreviations so I wrote a short bit of code to fix the problem and create a new format 'zipst' which can be used in place of the zipstate function without the errors. I added the format to my permanent SAS library so the time and memory cost are negated. Here is the new and improved Zipstate function format named 'zipst'

data source;
	length type hlo $1 fmtname $8 label $7;
	type = 'N';  *numeric format; 
	fmtname='zipst';
	do start=300 to 99999;
		label=zipstate(start);
		if label > '' then output; 
		end;
	start=.; hlo = 'O'; label='miss'; output; 
	run;	
proc format cntlin=source; run;