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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: RE: RE: Placing a string variable in a local/global


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: Placing a string variable in a local/global
Date   Tue, 27 Apr 2010 22:22:57 +0200

<>

See this example:


*************
clear*

input str10 X 
	bee
	lion
	duck
	rabbit
	bear
end

list, noo

local n = X[_N]

cou if X=="`n'"

*************


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss
Sent: Dienstag, 27. April 2010 22:21
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: Placing a string variable in a local/global


<>


You want your qualifier to be

*************
if X  =="`n'"
*************


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of George Chioran
Sent: Dienstag, 27. April 2010 22:15
To: statalist@hsphsun2.harvard.edu
Subject: st: Placing a string variable in a local/global

Dear Statalisters, 

I am assigning the names of certain observations from variable X to a
local/global with the command: local n = X[_N]. Say that now `n' has the
string "bear" stored in it.
Next I load a larger data base where variable X has several string
observations named bear among others.
For the final step I am trying to record the observations from variable Z
where `n' = X in a variable y. My code is this: 

local n = X[_N]
use "C:\Users\George\Desktop\Methodology\Final data1.dta", clear
gen y = Z if `n' == X

However when I do this, I get the error message: unrecognized command:  bear

Do you know how I could store observations from X so that when I load a
larger data set I can use them to see how many similar observations I have
in the larger data set? 


Thank you a lot for the help, 
George


      
*
*   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/

*
*   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/

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index