[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Sxpose : Process horizontal variables

From   "Nick Cox" <>
To   <>
Subject   st: RE: Sxpose : Process horizontal variables
Date   Tue, 15 Apr 2008 15:38:52 +0100

Oddly enough, Christian Weiss has exactly the same problem. 

Pure -xpose- problems are rare in my experience. 

And only very occasionally is -sxpose- (a user-written command from SSC)
the solution 

The main reason for that is the one you give: datasets of this kind
usually include
both string and numeric variables. 

You should check out -reshape-. With dataset 1

reshape long Firm, i(Description1) 

is a first step. 


P.S. for row sums, use addition (+) or check out -egen-. 

Richter, Ansgar

I am currently working on the following problem and it would be great if
someone had an idea how to proceed.

I have two datasets (exemplary illustration):

Dataset  1:

                Description1    Firm1           Firm2           Firm3
                        xyz     123              456             789
                        abc     321              654             987

Dataset 2:
                Firm            Employees       TotalAssets
                -----           ---------       -----------
                Firm1             123               123

First, I would like to "transpose" this dataset into a vertical order to
merge (later on) dataset1 with dataset2. However, as the dataset
string values as well as numerical values, neither the "xpose" nor the
"sxpose" command seems to be applicable.
(Xpose does exactly what I need, however I loose the string values,
(with force option) gives  a "type mismatch" error).
After applying "xpose", Dataset 1 looks a follows: (variable firm was

Dataset 2_xpose:

Firm  v_1    v_2
----  -----  ---
Firm1  123   321
Firm2  456   654
Firm2  789   987

First Question: Do you have any suggestion how I can prevent that the
string-variable ("description") is lost?

Second question:
I would like to calculate the sum of v_1 and v_2 for each row, how can I
implement this?

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index