Statalist The Stata Listserver


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

st: how to transpose few variables with their values


From   "Pritpal Marjara" <[email protected]>
To   <[email protected]>
Subject   st: how to transpose few variables with their values
Date   Fri, 13 Apr 2007 12:56:33 +0530

In a multiple choice question in a population based survey, I have asked for
the top three preferred brand of health services.

The total number of codes are twelve in number to choose from.  At the time
of data entry, the data was entered as twelve variables of brand names as
columns.  For each case, nine of the variables thus have missing values and
remaining 3 variables  have 1,2 or 3 numerical value as a preference in
order.    I am wondering if there is any way to transpose these twelve
variables with the values without affecting remaining 300+ variables in the
database.

For example, the data now is;

ID#	Brand1	Brand2	Brand3	Brand4	Brand5	Brand6	Brand7	....
001	-		3		-		1		-		2		-
002	1		-		-		2		-		3		-
003	-		1		3		-		2		-		-

And, I wish if the data would look like;

ID#	first		second	third

001	brand4	brand6	brand2
002	brand1	brand4	brand6
003	brand2	brand5	brand3


I am using Stata 8 version.

Appreciate guidance from the group in resolving this in a simpler way.


Thank you,

Pritpal

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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