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: outsheet and insheet
From
Sergiy Radyakin <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: outsheet and insheet
Date
Fri, 6 Dec 2013 01:03:06 -0500
Go by the book, use the -import delimited- command with the
stringcols(_all) option:
http://www.stata.com/stata13/importing-and-exporting-text-delimited-data/
Best, Sergiy Radyakin
On Fri, Dec 6, 2013 at 12:24 AM, rasool.bux <[email protected]> wrote:
> Dear Statalist,
>
> I have variables with multiple response codes in string variables. When I use outsheet with comma option and then use the insheet command again it converts the type of variables from string to numeric and omits the leading zeros from the values.
>
> Example:
>
> +------------------------+
> | var1 var2 |
> |------------------------|
> 1. | 01-001-1-01 01001101 |
> 2. | 01-018-3-02 01018302 |
> 3. | 01-018-5-01 01018501 |
> 4. | 01-019-1-02 01019102 |
> 5. | 11-274-1-01 11274101 |
> |------------------------|
> 6. | 11-275-1-01 11275101 |
> 7. | 09-002-1-01 09002101 |
> 8. | 09-013-1-02 09013102 |
> 9. | 09-019-2-01 09019201 |
> +------------------------+
>
> . desc
> -------------------------------------------------------------
> storage display value
> variable name type format label variable label
> -------------------------------------------------------------
> var1 str11 %11s
> var2 str8 %9s
> -------------------------------------------------------------
>
> . outsheet using "tmp.csv", comma
>
> . insheet using "tmp.csv", comma
> (2 vars, 9 obs)
>
> . list
>
> +------------------------+
> | var1 var2 |
> |------------------------|
> 1. | 01-001-1-01 1001101 |
> 2. | 01-018-3-02 1018302 |
> 3. | 01-018-5-01 1018501 |
> 4. | 01-019-1-02 1019102 |
> 5. | 11-274-1-01 11274101 |
> |------------------------|
> 6. | 11-275-1-01 11275101 |
> 7. | 09-002-1-01 9002101 |
> 8. | 09-013-1-02 9013102 |
> 9. | 09-019-2-01 9019201 |
> +------------------------+
>
> . desc
> -------------------------------------------------------------
> storage display value
> variable name type format label variable label
> -------------------------------------------------------------
> var1 str11 %11s
> var2 long %12.0g
> ---------------------------------------------------
>
> Is there any way to handle this kind of issue? Or there any option to retain the original type by using insheet.
>
> Thanks & regards
> Rasool Bux
>
> ________________________________
>
> This e-mail may contain information that is privileged or confidential. If you are not the intended recipient, please delete the e-mail and any attachments and notify us immediately.
>
>
> *
> * 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/