Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: Combining and repeating value from another dataset

 From Michael LeGower To statalist@hsphsun2.harvard.edu Subject Re: st: Combining and repeating value from another dataset Date Mon, 15 Apr 2013 08:54:26 -0400

And it seems like if you wanted to do that dynamically (i.e. you have a bunch of these dataset pairs and you don't want to have to manually retrieve all of the values of e for each Y dataset), you could do something like the following:
```
use Y.dta
scalar e_value = e[1]
use X.dta, clear
gen e = e_value

On 4/15/2013 2:33 AM, statalist-digest wrote:
```
```------------------------------

Date: Sun, 14 Apr 2013 11:38:43 +0100
From: Nick Cox<njcoxstata@gmail.com>
Subject: Re: st: Combining and repeating value from another dataset

You don't need anything fancy.

Suppose the one value in Y.dta is 42.

In X data, you just go

gen e = 42

That's it. (If the value is a string value, say "Stata is easy", it's
the same story.)

That said, why do this? What analyses need it?

Nick
njcoxstata@gmail.com

On 14 April 2013 06:19, Rahber Thariani<thariani@gmail.com>  wrote:

```
```>A question to which I am sure there is a simple answer, but as a novice in
>Stata, one I am having a hard time finding.
>
>I have a dataset with variables a, b, c and d (stored in X.dta). There are
>
>In another dataset I have only variable e(stored in Y.dta). There is only
>one observation.
>
>I want to create a composite dataset with variables a, b, c, d  and e. I
>wish to repeat the same value of e 5,000 times in my new dataset for each of
>the existing 5,000 observations of a, b, c, and d.
>
>What do you suggest to create this structure?
```
```
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```