Hello, I am wanting to separate the FIPs code into just state and county number. Any advice?
Shown below is what I am wanting
| What I have | What I want | |
| FIPS | State | County |
| 5017 | 5 | 17 |
| 5041 | 5 | 41 |
| 20107 | 20 | 107 |
| 46097 | 46 | 97 |
Are those numbers?
data want;
set have;
state = int(fips/1000);
county = mod(fips,1000);
run;
Or strings?
data want;
set have;
state=put(int(input(fips,32.)/100),Z2.);
county=put(mod(input(fips,32.),100),Z3.);
run;
Is your current FIPS variable numeric or character? Do you want character or numeric State and County? If character do you want the leading 0 that should be present to avoid confusion?
Are those numbers?
data want;
set have;
state = int(fips/1000);
county = mod(fips,1000);
run;
Or strings?
data want;
set have;
state=put(int(input(fips,32.)/100),Z2.);
county=put(mod(input(fips,32.),100),Z3.);
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.