BookmarkSubscribeRSS Feed
Yulka
Calcite | Level 5
There are 5 tables:
1. Year05d: 5 variables + 2 keys: zip naics
2. Year06d: 5 variables + 2 keys: zip naics
3. Year05t: 3 variables + key: zip
4. Year06t 3 variables + key: zip
5. look-up table: 2 variables: naics sic

I need one table that is unique at zip+naics level and contains all observations and all the variables from all 5 tables.
With data step the logic was as following:
1. merge Year05d Year06d by zip naics
2. merge Year05t Year06t by zip
3. merge step1 and step2
4. merge step3 and look-up table by naics

how do i do that with sql in one step?
1 REPLY 1
1162
Calcite | Level 5
I would start with something like this. Keep in mind that there's only one way to get all the observations and also be unique at the zip+naics level and that is if your first two tables only have one observation per zip+naics level and your second two tables only have one observatikon per zip level.

[pre]
proc sql;
create table all as
select *
from year05d a, year06d b, year05t c, year06t d, look-up table e
where a.zip = b.zip
and a.naics = b.naics
and c.zip = d.zip
and c.zip = a.zip
and a.naics = e.naics;
quit;
[/pre] Message was edited by: 1162

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 652 views
  • 0 likes
  • 2 in conversation