BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ccaudillo100
Obsidian | Level 7

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 haveWhat I want
FIPSStateCounty
5017517
5041541
2010720107
460974697
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

3 REPLIES 3
ballardw
Super User

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?

Tom
Super User Tom
Super User

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;
ccaudillo100
Obsidian | Level 7
For me it was just numeric but both are helpful for me in the future! Thank you so much!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1020 views
  • 2 likes
  • 3 in conversation