Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: AW: AW: st: string variable question


From   Eric Booth <ebooth@ppri.tamu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: AW: AW: st: string variable question
Date   Mon, 29 Mar 2010 10:46:09 -0500

>

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
ebooth@ppri.tamu.edu
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: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Eric Booth
> Gesendet: Montag, 29. März 2010 17:12
> An: statalist@hsphsun2.harvard.edu
> 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
> ebooth@ppri.tamu.edu
> 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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index