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]

AW: AW: AW: st: string variable question


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: AW: AW: st: string variable question
Date   Mon, 29 Mar 2010 18:05:49 +0200

<> 


Similar to Nick`s
http://www.stata.com/statalist/archive/2008-03/msg00385.html




HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Eric Booth
Gesendet: Montag, 29. März 2010 17:46
An: [email protected]
Betreff: Re: AW: AW: st: string variable question

>

Martin's right.  I hadn't noticed this error before.

Stata doesn't need "end" for additional variables added via -input-, so for
the brand variable just leave off "end" and it will add the variable without
error:
***
clear*
inp A1 A2
1 2
2 3
3 4
5 6
end


inp str25  brand
"Cheerios" 
"Wheaties" 
"Frosted"
"other"

**or **
#delimit ;
inp str25  brand2; "Cheerios"; "Wheaties"; "Frosted" ; "other" ;
#delimit cr
***

~ Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754



On Mar 29, 2010, at 10:27 AM, Martin Weiss wrote:

> 
> <> 
> 
> 
> 
> " No, you can put the -input- command into a do-file, you don't have to
use
> it from the command line.  "
> 
> 
> 
> I get an error when running your earlier example as a do-file, though:
> 
> 
> . end
> unrecognized command:  end
> r(199);
> 
> 
> *************
> clear*
> inp A1 A2
> 1 2
> 2 3
> 3 4
> 5 6
> end
> 
> inp str25  brand
> "Cheerios" 
> "Wheaties" 
> "Frosted"
> "other"
> end
> *************
> 
> 
> 
> HTH
> Martin
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Eric Booth
> Gesendet: Montag, 29. März 2010 17:12
> An: [email protected]
> Betreff: Re: AW: st: string variable question
> 
>> 
> On Mar 29, 2010, at 10:00 AM, Data Analytics Corp. wrote:
>> This looks like it would work, But it's interactive. 
> 
> 
> No, you can put the -input- command into a do-file, you don't have to use
it
> from the command line.  
> 
> Also, you could use -replace- in a loop (-foreach- or -while- possibly in
> combination with -tokenize-)  to speed up that process.  
> Another option might be to use -merge- to merge in a column of brand
names.
> 
> 
> ~ Eric
> __
> Eric A. Booth
> Public Policy Research Institute
> Texas A&M University
> [email protected]
> Office: +979.845.6754
> Fax: +979.845.0249
> http://ppri.tamu.edu
> 



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