Statalist


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

AW: st: SV: AW: Output from tabulate to a matrix


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: SV: AW: Output from tabulate to a matrix
Date   Thu, 21 Jan 2010 17:36:46 +0100

<> 

The emply line is not meant to be there between "Jönköping" and
"Kronoberg"...


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Martin Weiss
Gesendet: Donnerstag, 21. Januar 2010 17:28
An: [email protected]
Betreff: AW: st: SV: AW: Output from tabulate to a matrix


<> 

Just switch the delimiter temporarily:


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

#delimit ;

local  mynames   "Stockholm  Uppsala  Södermanland  Östergötaland  Jönköping

Kronoberg  Kalmar  Gotland  Blekinge  Skåne  Halland  VästraGötaland 
Värmland  Örebro  Västmanland  Dalarna  Gävleborg  Västernorrland  Jämtland
Västerboten  Norrbotten" ;

#delimit cr

ma di
*************

Some text editors, such as UltraEdit, also feature a "word-wrap" which
renders long lines readable...


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Tomas Lind
Gesendet: Donnerstag, 21. Januar 2010 17:20
An: [email protected]
Betreff: SV: st: SV: AW: Output from tabulate to a matrix

Thanks Martin and William for all your help. Very instructive. 

One last question. -local mynames- contains lots of areas so it would be
nice to have some line-breaks (so it is not just one long row in my
do-editor). 

local  mynames   "Stockholm  Uppsala  Södermanland  Östergötaland  Jönköping
Kronoberg  Kalmar  Gotland  Blekinge  Skåne  Halland  VästraGötaland
Värmland  Örebro  Västmanland  Dalarna  Gävleborg  Västernorrland  Jämtland
Västerboten  Norrbotten"


/Tomas



-----Ursprungligt meddelande-----
Från: [email protected]
[mailto:[email protected]] För Martin Weiss
Skickat: den 21 januari 2010 16:52
Till: [email protected]
Ämne: AW: st: SV: AW: Output from tabulate to a matrix


<> 


Tomas may also want to read up on this issue in manual [U], section 18.3.9.,
where the "from the inside" evaluation of nested -macro-s is explained.



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von William Gould,
StataCorp LP
Gesendet: Donnerstag, 21. Januar 2010 16:36
An: [email protected]
Betreff: Re: st: SV: AW: Output from tabulate to a matrix

Tomas Lind <[email protected]> asked, 

> Is it possible to store names in a matrix for example "east",
> "west", "north", "south" and then display the one that I want, for
> example the 3:rd element "north"?

and Martin Weiss <[email protected]> replied, 

> Could well be as easy as
> 
> *************
> local mynames "nameone nametwo namethree namefour namefive"
> 
> token `mynames'
> 
> local mycount: word count `mynames'
> 
> forv i=1/`mycount'{
>         //-lincom- statement goes here
>         di in r "``i''"
> }
> *************

and that seemed to be a hit because Tomas then replied, "Perfect."

Given that, here's another, related solution.  Start by defining 
separate macros for each member of the list:

        . local name1 "north"
        . local name2 "south"
        . local name3 "east"
        . local name4 "west"

Now say we want to display the `i'th name.  We can type:

        . display "`name`i''

For instance, if `i' contained 3, 

        . local i = 3 
        . display "`name`i''"
        east

That works because `name`i'' first expands to `name3' (Stata goes inside 
and substitutes the contents of i for `i'), and then `name3' expands to 
east in the usual way. 

-- Bill
[email protected]
*
*   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/


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index