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, is already up and running.

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

st: Problem with wildcards

From   Lisa Cook <>
Subject   st: Problem with wildcards
Date   Mon, 4 Mar 2013 16:36:28 -0500


I'm having a problem using wildcards. I'm using Stata 11.2 for Windows.

I have a list of variables: psych1 - psych42. I would like to create a
new variable called "anypsych" that takes the value of 0 if all the
variables psych1-psych42 are 0 or missing, and takes the value 1 if
any of psych1-psych42 are 1.

My code:

gen anypsych = 0
replace anypsych = 1 if psych* == 1

I get the error "psych* invalid name".

Can anyone tell me why it's an invalid name and how I can achieve this
objective? I also have a bunch of other variables that I need to do
the same thing for, so advice on how to approach this would be a huge

*   For searches and help try:

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