Statalist The Stata Listserver


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

st: Re: problem with a list returned by stata (r(varlist))


From   "Sergiy Radyakin" <[email protected]>
To   <[email protected]>
Subject   st: Re: problem with a list returned by stata (r(varlist))
Date   Fri, 23 Feb 2007 13:55:26 +0100

Hi Valerie,

by adding another pair of ` ' in your second -local- statement you ask Stata to evaluate the list and assign the value to the macro. The evaluated list will be exactly what you see on the screen. The numbers are the values of the variables of liste1 for observation 1. Similarly you can
di VolBR4 /*or any other variable */
You must see the first observation in VolBR4!

Regards,
Sergiy




----- Original Message ----- From: "Val�rie Orozco" <[email protected]>
To: <[email protected]>
Sent: Friday, February 23, 2007 1:44 PM
Subject: st: problem with a list returned by stata (r(varlist))



Hello,

What I want to do is to store lists (in a macro) of some variables in my data.
I use the command "ds" to have them and I thought that thanks to the return list r(varlist) I would be able to play with this in my program (make some differences and others manipulations of macrolists)...but ir doesn't work...

My example is the following :

ds Vol* /*I want Stata to show me all the variables beginning by "Vol" in my data*/
local liste1 `r(varlist)' /*I put it in a local list*/
di "`liste1'" /*to test it : it woks*/
local liste1bis `"`liste1'"' di `liste1bis' /*and it is a funny result*/

ds Vol*
VolBR4_seg0 VolBR1 VolBR5 VolBR9 VolMN3 VolMR5 VolS01MN1 VolS01MN5
Vol0BR4_seg0 VolBR2 VolBR6 VolMN1 VolMN5 VolMR3 VolS01MN2 VolS01BR4
VolBR4_seg1 VolBR3 VolBR7 VolMN2 VolMR1 VolMR4 VolS01MN3
Vol0BR4_seg1 VolBR4 VolBR8 VolMN4 VolMR2 Volmois VolS01MN4

. local liste1 `r(varlist)'

. di "`liste1'"
VolBR4_seg0 Vol0BR4_seg0 VolBR4_seg1 Vol0BR4_seg1 VolBR1 VolBR2 VolBR3 VolBR4 VolBR5 VolBR6 VolBR7 VolBR8 VolBR9 VolMN1
> VolMN2 VolMN4 VolMN3 VolMN5 VolMR1 VolMR2 VolMR5 VolMR3 VolMR4
Volmois VolS01MN1 VolS01MN2 VolS01MN3 VolS01MN4 VolS0
> 1MN5 VolS01BR4

. local liste1bis `"`liste1'"'

. di `liste1bis'
133008.88133008.8850295.1650295.1621709.86553108.0783532.6653183304.05706.5600625242.53178350.60974817.94556640.7429417 9.91461350.7854565.400414064.5413353.52565.5650.400002...262361.2294179.91461350.78514064.5414565.40043353.52183304.05

It seems that strings in a list returned by the "return list" command are coded...very stranged, isn't it?
If someone has an idea...

thank you very much for trying to help me


--

***********************
Val�rie Orozco
INRA ESR Toulouse
ESR INRA - BP52627 - 31326 Castanet Tolosan Cedex FRANCE
[email protected]
05-61-28-50-97
***********************




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