Search results
Results from the WOW.Com Content Network
Well, first, I want to delete any zip code that isn't 5 characters long. All zip codes must be 5 characters long (which can include leading 0). If it's character, that's fine, for this part, and this part looks easy to do. Second, I want to delete any values that are not all numbers.
I have a zip code variable in a dataset that includes both 5- and 9-digit zip codes. I want all of them to be 5-digits but am having trouble extracting the first 5 digits of the variable. It is an extensive list, but some examples are 15009, 15208, 191451652, 193760024. When I try to use substr, data cases; set cases; zip=substr (zip_char,1,5);
Re: 3-digit ZCTA data set. You would need to create the new 3-digit zip variable, and then use 'proc gremove' to remove all the internal boundaries within those 3-digit areas. Here's the gremove doc: SAS/GRAPH (R) 9.4: Reference, Second Edition.
The function zipcitydistance uses sashelp.zip (as documented) and that dataset contains only the five digit zip codes. So you need another function and data-source to calculate distances. Proc geocode could be used here, you want to read the documentation.
Variable zipcode is read with format$10. It reads zip codes in the form 07417 or 07417-1280 Create variable_9digit. It equals 1 if zipcode has a hyphen separating the fifth and seven digits. Otherwise it equals 0. Write the statements three ways, using the length, index, ad substr functions. /* using length function*/.
By 9-digit ZIP I assume you mean ZIP+4. The only ZIP+4 data set currently supplied by SAS is the PROC GEOCODE lookup data used for ZIP+4 geocoding. It was generated from Census Bureau TIGER files and is in the downloads section of the SAS Maps Online site. However, the current data set does not contain county values.
Re: converting 5 digit date code. Posted 02-11-2015 12:43 PM (33409 views) | In reply to Haikuo. So assuming you meant 12JAN2014 and not 01DEC2014 then your value is consistent with Excel's date numbering. You can adjust it easily. date=date -'01JAN1960'd + '01JAN1900'd -2 ; format date date9.
I have a similar problem. My zip variable data has following values: zip. 123456789. 123456789. 1234. 1234. 12345. 123456789. 12345. 12345. 1234. 123456789 . I want to get a single variable with: first 5 digit from 9 digit zip var; add leading zero where there is 4 digit zip and; keep five digit zip value as it is. Thanking you in advance!
Usual recommendation is to add leading zeros, not trailing zeros. Hard to know which is useful that way. There are many ways to do this but if all are 10 this is easy. Assuming this is character vairable: if length (variable) = 10 then ID_new = catt ('000', variable); If you really want it trailing, reverse the order of the arguments in the ...
Here is an example that works, using ZIPCITYDISTANCE (), for valid U.S. zip codes: ; run; data want; set have; distance = zipcitydistance(HQ_ZIP, AFF_ZIP); run; Solved: Hello, I have SAS 9.4. I am trying to measure the distance between two cities. I have HQ_ZIP variable and Affiliate_ZIP variable.