Bookmark and Share

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.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Extracting numbers from code


From   daniel klein <klein.daniel.81@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Extracting numbers from code
Date   Mon, 12 Nov 2012 17:23:22 +0100

Oops.

"assumtion" shoud read assumption, but this is not why I am writing
again. The code for dummies 2-11 should work fine, however my code to
create the first dummy is not a good idea. Instead try

g byte dummy1 = (substr(strofreal(item), 1, 1) == "1") &
!(inlist(substr(strofreal(item), 2, 1), "0", "1"))

Best
Daniel

-- 
Sanja,

[...]

Create the dummy for item 1 as

g byte dummy1 = (substr(strofreal(item), 1, 1) == "1")

Best
Daniel
-- 
Good day.
I have received a dataset from a survey in which numerous questions
asked respondents to check all that apply.
As an example, one such question had 11 possible items that
respondents could check.
The data is coded in such a way that if a respondent checked item 2,
item 4, item 7, item 10 and item 11, then the response in the dataset
is coded 2471011.
I need to create dummy variables for each item.
[...]
Any advice would be greatly appreciated.
Kind regards
Sanja
*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index