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: populating a local macro with a stringvariable


From   Daniel Pilsgaard Henriksen <henriksen.dp@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: populating a local macro with a stringvariable
Date   Mon, 19 Dec 2011 13:33:40 +0100

Dear Statalist

I'm new to using macros in stata, and I'm having trouble populating
local macro with a variable containing strings sorted by their length
instead of their order of apperence. Here's an example of my problem

inp str30 alt
"a"
"aaa"
"b"
"bb"
"c"
"d"
"e"
"f"
"g"
end


gen len = length(alt)
sort length
levelsof alt, loc(i)
di `"`i'"'

I'm sure there're a easy way of doing this, but I've tried for some
time now and it's not showing up.

Cheers
Daniel
--
Daniel Henriksen
Ph.d. studerende, læge
Infektionsmedicinsk afd Q / Akut Modtage Afdelingen
Odense Universitetshospital

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