Statalist


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

Re: st: RE: Tabulation task


From   "Eva Poen" <[email protected]>
To   Statalist <[email protected]>
Subject   Re: st: RE: Tabulation task
Date   Fri, 15 Aug 2008 10:23:50 +0100

Serguei,

if I understand correctly, you have two files.
File 1:
Name    Country V1  V2  V3
Mr. X   A       1   2   1
Ms. Y   B       4   0   2

File 2:
Vote_id Vote_issue
1       important stuff
2       something else
3       anything


In order to merge Vote_issue into file 1, you need to -reshape- file 1
from wide to long:

reshape long V, i(Name) j(Vote_id)

which leads you to

Name    Country Vote_id V
Mr. X   A       1       1
Mr. X   A       2       2
Mr. X   A       3       1
Ms. Y   B       1       4
Ms. Y   B       2       0
Ms. Y   B       3       2

You can then -merge- on Vote_id. I'm still not quite sure what you
want your tabulations to look like, but that should be an easy problem
to solve once you have the data together.

Hope this helps,
Eva


2008/8/15 Martin Weiss <[email protected]>:
> Sounds like a problem for -destring- -tostring- -encode- -decode- to me...
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Serguei Kaniovski
> Sent: Friday, August 15, 2008 10:45 AM
> To: [email protected]
> Subject: Re: st: RE: Tabulation task
>
> The problem is that the VALUES of the variable Vote_id in second file
> are contained in the NAMES of the Vx varibales in the first file. And I
> cannot figure out how to work with this.
>
> Serguei
>
> Martin Weiss schrieb:
>> Not sure whether I get this problem right: if there is a unique key that
>> ties the person`s vote in the first file to the Vote _id in the second
> file,
>> then -merge- on the unique key and - tabulate- (-tab2-) afterwards.
>>
>> HTH
>> Martin
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Serguei
> Kaniovski
>> Sent: Friday, August 15, 2008 9:39 AM
>> To: [email protected]
>> Subject: st: Tabulation task
>>
>> Hallo,
>>
>> I am stuck with the following tabulation tast. I have two datafiles. One
>> contains the following variables:
>>
>> Name, Country, V1, V2, V3, V4, ... large number
>> where Vx signifies a persons vote on issue x (numeric, categorical)
>>
>> A second file contains the issue types (string) of each vote as follows:
>>
>> Vote_id, Vote_issue
>> where Vote _id is numeric and corresponds to 1, 2, 3, 4, ..., Vote_issue
>> is a string decribing the voting issue.
>>
>> How can I read in the issue types and tabulate the V-variables by issue
>> and country?
>>
>> Thank you very much,
>> Serguei
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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