How do I Join 2 datasets WITHOUT a BY variables?

Reply
New Contributor
Posts: 3

How do I Join 2 datasets WITHOUT a BY variables?

How do I Join 2 datasets WITHOUT a BY variables? I have a file of ZIP Codes 30,000 observations named work.ZIP. I want to horizontally add 100 variables from table WORK.DATA with 1 observation and 9 variables. How do I get the 9 variables from WORK.DATA and copy for all 30,000 ZIP codes without a common BY field to JOIN? Any suggestions? THANK YOU!

WORK.ZIP

proc print data=WORK.ZIP (obs=12)

ZIPCODEFPP01FPP02
010011127
0100234329
0100371
01005101
01007322
0100810
0101040
0101100
0101200
0101355047
0102040330
010221288

WORK.DATA (doesn't have a ZIP Code to join with WORK.ZIP)

proc print data=WORK.DATA

ObsPZM01PZM02PZM03PZM04PZM05PZM06PZM07PZM08PZM09
139.2955.5454.8472.761.5269.3848.2158.4731.83
Trusted Advisor
Posts: 1,929

Re: How do I Join 2 datasets WITHOUT a BY variables?

You could of course do a merge without a BY statement, or you could try something with a SET statement, like

data final;

     if _n_=1 then set data;

     set zip;

run;

but ... since I can't visualize the end result you want, nor can I figure it out from your words, I would like to see an example of the final merged data set you would like to have.

Super Contributor
Posts: 644

Re: How do I Join 2 datasets WITHOUT a BY variables?

Posted in reply to PaigeMiller

Or (untested)

Proc SQL ;

     Create table datazip as

          select *

          from data, zip

          ;

Run ;

Richard

New Contributor
Posts: 3

Re: How do I Join 2 datasets WITHOUT a BY variables?

Posted in reply to RichardinOz

Thanks so much for your help! This solved my problem.

New Contributor
Posts: 3

Re: How do I Join 2 datasets WITHOUT a BY variables?

Posted in reply to PaigeMiller

Thanks for your response!

Ask a Question
Discussion stats
  • 4 replies
  • 187 views
  • 1 like
  • 3 in conversation