Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging question

Status
Not open for further replies.

Medvedeff

Instructor
Feb 12, 2008
29
US
I have two datasets, one with a single row of observations and one with 10 rows of observations. I need to merge them in a way so that the single observation is repeated 10 times. Consider the following:

Dataset 1: Dataset 2:
X Y Z A1 B1 C1
A1 B2 C2
A3 B3 C3
...
A10 B10 C10

I need to merge them so that the final dataset is like this:

Data Composite:
X Y Z A1 B1 C1
X Y Z A2 B2 C2
X Y Z A3 B3 C3
...
X Y Z A10 B10 C10

Any ideas? Your help is GREATLY appreciated!
 
Nevermind, I figured it out and put it into a macro...

data combined&n;
if _n_=1 then set beta&n;
set keep&n;

run;

Thanks anyways!
 
An alternative, if you want to join a single record from one dataset to every record of another, is to add a key variable to both with a constant value. For example, create a variable "KEY" on both datasets and set it to 1 for every record. Then join the two datasets together on KEY.
Also, in SAS-speak, an Observation is a record or row. Columns are known as columns or variables. I got a bit confused at first when I read your initial question :).


Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Thanks for the tip!

My apoligize about the confusion over the language...different technical jargons dont overlap as much as I would like.
 
No need to apologise. Wouldn't it be lovely if all programming languages used the same jargon?

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top