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]

Re: st: insheet and strings


From   Rebecca Pope <[email protected]>
To   [email protected]
Subject   Re: st: insheet and strings
Date   Fri, 8 Mar 2013 08:19:04 -0600

Jeph,
-infile- won't work with ";" as a delimiter. This is explicit in the
-import- overview, but only implied with -infile-. If Sonja has the
option of a comma-delimited file, she could do the following. However,
depending on the content of her data & the number of string variables
she has, Nick's solution might be the best one.

input x str2 s
1 "04"
2 "10"
end
list
format s

outsheet using "test.csv", replace
infile x str2 s using "test.csv" in 2/l, clear
format s
list, noobs

The "in 2/l" keeps it from reading the variable names on the first line.

Perhaps we should add this to our wishlist: ability to either specify
the delimiter for -infile- or the format for -insheet-.

Regards,
Rebecca

On Fri, Mar 8, 2013 at 7:54 AM, Jeph Herrin <[email protected]> wrote:
> You might find -infile- useful:
>
>
> input x str2 s
> 1 "04"
> 2 "10"
> end
> list
> format s
>
> outsheet using "test.csv", delim(";") replace
> infile x str2 s using "test.csv", clear
> format s
>
>
>
>
> On 3/8/2013 8:12 AM, Sonja Wehberg wrote:
>>
>> Hi!
>>
>> I frequently use insheet. Unfortunately it sometimes converts string
>> variables. Can I prevent that (without adding an alphanumeric suffix)?
>>
>> Example (version 12):
>>
>> input x str2 s
>> 1 "04"
>> 2 "10"
>> end
>> list
>> format s
>>
>> outsheet using "test.csv", delim(";") replace
>> insheet using "test.csv", clear delim(";")
>> format s
>>
>>
>> Best regards
>> Sonja
>>
>>
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index