Statalist


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

Re: st: subvarname and list


From   Michael Manti <statboy3000@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: subvarname and list
Date   Mon, 3 Aug 2009 07:31:11 -0400

Joerg,

Here's an example that does what you request.


. set obs 100
obs was 0, now 100

. gen var51 = runiform()

. label variable var51 "since years"

. char var51[varname] "`: variable label var51'"

. list var51 in 1/10, subvarname

     +----------+
     | since ye |
     |----------|
  1. | .1369841 |
  2. | .6432207 |
  3. | .5578017 |
  4. | .6047949 |
  5. |  .684176 |
     |----------|
  6. | .1086679 |
  7. | .6184582 |
  8. | .0610638 |
  9. | .5552388 |
 10. | .8714491 |
     +----------+

. gen var52 = runiform()

. gen var53 = runiform()

. label variable var52 "since months"

. label variable var53 "since days"

. foreach var of varlist * {
  2. char `var'[varname] "`: variable label `var''"
  3. }

. list * in 1/10, subvarname

     +--------------------------------+
     | since ye   since mo   since da |
     |--------------------------------|
  1. | .1369841   .7767971   .5227695 |
  2. | .6432207    .643114   .2102229 |
  3. | .5578017   .3833295   .5534564 |
  4. | .6047949   .0057233   .9088587 |
  5. |  .684176   .8772233   .2769888 |
     |--------------------------------|
  6. | .1086679   .6526399   .3915251 |
  7. | .6184582   .2033027   .0396565 |
  8. | .0610638   .6363281   .4235426 |
  9. | .5552388    .366027   .6125947 |
 10. | .8714491   .8637221   .5015944 |
     +--------------------------------+

Hope this helps,

Michael Manti


On Aug 3, 2009, at 6:49 AM, Joerg Eulenberger wrote:

Dear Statausers,
I have a question to the list-command. I don' t want the varname in the list-output-header, i want the varlabel. All i found is the char- command and than the subvarname option in the list-command. It is possible to say Stata in the char-command use the varlabel as subvarname? For all Variables in the Dataset? I don´t want to type for every each variables a new subvarname like this:

char var51[varname] "since years"

Thanks,
Jörg



*
*   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   |   What's new   |   Site index