BookmarkSubscribeRSS Feed
wernie
Quartz | Level 8

I have a file where I need to expand to include all counties.

 

The first file that has the data I need (start and end month and days) does NOT have all counties. It looks like this:

 

STATE   COUNTY    FIPS5    START_MONTH   START_DAY  END_MONTH    END_DAY

01                                 01              3                           1                       10                      31

01             073         01073             1                           1                       12                      31

02                                 02              4                           1                       10                      30

02             090         02090             1                           1                       12                      31   

04                                 04              1                           1                       12                      31

04             005         04005             1                           1                       12                      31

04             007         04007             1                           1                       12                      31

 

I need to merge this with a file that has all state and county codes to fill in values for ALL counties. I just want to be able to expand the counties in the new file and wherever the county value is blank, I want to apply the start_month, start_day, end_month, and end_day values to those expanded counties, while leaving the values for the rows where county DOES have a value in the data file.

 

Essentially, I want to expand the new file to look something like this (dots are just to continue rows up to observation where something would be different):

 

STATE   COUNTY  FIPS5    START_MONTH   START_DAY  END_MONTH    END_DAY

01             001             01001         3                           1                       10                      31

01             003             01003         3                           1                       10                      31

01             005             01005         3                           1                       10                      31

01             007             01007         3                           1                       10                      31

…           ……..               .                             .                        ..                        ..

01             073             01073         1                           1                       12                      31

02             013             02013         4                           1                       10                      30

02             016             02016         4                           1                       10                      30

…           ……..               .                             .                       ..                         ..

02             090             02090         1                           1                       12                      31

 

I hope this makes sense. How can I expand to fill in all county values? I'm thinking to take a county reference file and merge by county and that might fill in the counties where they aren't listed, but I still need to retain the counties that have a different start and end month and day. Thank you!

2 REPLIES 2
ballardw
Super User

To begin with you don't have County in the first data set so it is not obvious what is going on.

I can guess that your Fips5 is related to county but you should really provide a complete description.

 

And since your second set is missing values for county as presented it gets even harder to tell what is going on.

wernie
Quartz | Level 8
Edited original post. I just need to be able to expand the counties in the dataset to have all counties included (could merge with some county reference file).

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 1967 views
  • 0 likes
  • 2 in conversation