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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.