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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.