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

I am working with 2 data sets  that need to coordinate. They are set up as follows:

 

Table 1. Date_Zip table with numerical value for each date zip combo:

Date _90001 _90002 ... _96162

01-01-2016 15.35 30.29 39.08

...

12-31-2020 30.55 62.75 55.14

 

Table 2. Risk and threshold by zip

Zip  Risk (numerical) Threshold (numerical)

90001 1.0 18.36

90001 1.5 20.16

90001 2.0 23.75

90001 2.5 25.11

...

96162 1.0 23.22

96162 1.5 25.45

96162 2.0 28.85

96162 2.5 30.44

 

Am trying to figure out the best way to work with these tables. The goal is to determine a score for each table 1 zip date value based on the table 2 zip specific risk and threshold values.

* the risk values will determine the nominal score (<1 risk = score 0, 1-1.5 risk = score 1, 1..5-2.0 risk = score 2, 2.0-2.5 risk = score 3, >2.5 risk = score 4). 

 

My final table would have a unique score for each day for each zip. 

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Convert your first dataset into something that more closely resembles your description.  A series of DATE/ZIP pairs.  

proc transpose data=Date_Zip out=tall;
  by date ;
  var _: ;
run;
data tall;
  set tall;
  zip=input(substr(_name_,2),5.);
run;

Now you can combine the data by ZIP value.  You might also want to rename the generated COL1 variable to something that is more meaningful to make the code clearer.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Convert your first dataset into something that more closely resembles your description.  A series of DATE/ZIP pairs.  

proc transpose data=Date_Zip out=tall;
  by date ;
  var _: ;
run;
data tall;
  set tall;
  zip=input(substr(_name_,2),5.);
run;

Now you can combine the data by ZIP value.  You might also want to rename the generated COL1 variable to something that is more meaningful to make the code clearer.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 709 views
  • 1 like
  • 2 in conversation