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;
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.