Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: RE: How to read a particular value in a variables then save it to macro?


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: How to read a particular value in a variables then save it to macro?
Date   Sat, 28 Aug 2010 15:00:31 +0200

<>

*************
clear*
inp X str1 STR
1 a
2 b
3 c
4 d
5 e
6 f
7 g
8 h
9 i
10 j
end
local temp=STR[2]
di "`temp'"
*************


HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of STATALIST
STATALIST
Sent: Samstag, 28. August 2010 14:29
To: [email protected]
Subject: st: How to read a particular value in a variables then save it to
macro?

Dear All,

I would like to know if it is possible to read and save a particular
value in a dta file to macro. I mean one particular value of a
variable rather than the "variable itself".
I have a dataset of 2 columns and ten rows. One column has the
column_name of X which has a value of 1 to 10. The first row is 1, the
second is 2,.....
And I have another column which has a column_name of STR which is made
up of string, the first row is "a", the second is "b",.....

Can I pinpoint one particular cell in this dataset and save the
contents of this particular cell to a macro?
eg I want to ask STATA to give me the value of STR  when X=2, the
value should be "b".

local temp = STR if X==2 (of course, it does not work and that's why I
ask for help.)

Thank you very much for your help and have a nice day.
Allen
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index