Quantcast

Adding rows to datasheet

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Adding rows to datasheet

Sripal Kumar
Hi,

This might seem like a no brainer to some of you.  I frequently run
into the trouble where I need to add rows to a previous stata
datasheet.  When I copy rows from excel and try to add to an existing
stata datasheet, it seem to wipe off the header and replace it with
the the newly added first row.  This happens even though I am adding
data to say the 20th row.  The newly inserted row will always replace
the header.  What am I doing wrong here?

To explain it a bit better:  My header in stata reads--no. of
patients, dead etc.  If I add an extra row from excel which has say
2345 and 2...this row deletes the header and the header will now read
as 2345 and 2 instead of no. of patients, dead.
thanks,
Sripal.
*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

AW: Adding rows to datasheet

Martin Weiss-5

<>

For a single row, you could also issue commands in the command window:

*************
input
232 453
end
*************

assuming you have two variables in your dataset. This will append them to
the end of your dataset w/o altering anything else...


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [hidden email]
[mailto:[hidden email]] Im Auftrag von Sripal Kumar
Gesendet: Dienstag, 23. März 2010 14:48
An: statalist
Betreff: st: Adding rows to datasheet

Hi,

This might seem like a no brainer to some of you.  I frequently run
into the trouble where I need to add rows to a previous stata
datasheet.  When I copy rows from excel and try to add to an existing
stata datasheet, it seem to wipe off the header and replace it with
the the newly added first row.  This happens even though I am adding
data to say the 20th row.  The newly inserted row will always replace
the header.  What am I doing wrong here?

To explain it a bit better:  My header in stata reads--no. of
patients, dead etc.  If I add an extra row from excel which has say
2345 and 2...this row deletes the header and the header will now read
as 2345 and 2 instead of no. of patients, dead.
thanks,
Sripal.
*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AW: Adding rows to datasheet

Sripal Kumar
In reply to this post by Sripal Kumar
Can that be done for an entire row with say 25 variables

On Tue, Mar 23, 2010 at 9:59 AM, Martin Weiss <[hidden email]> wrote:

>
> <>
>
> For a single row, you could also issue commands in the command window:
>
> *************
> input
> 232 453
> end
> *************
>
> assuming you have two variables in your dataset. This will append them to
> the end of your dataset w/o altering anything else...
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: [hidden email]
> [mailto:[hidden email]] Im Auftrag von Sripal Kumar
> Gesendet: Dienstag, 23. März 2010 14:48
> An: statalist
> Betreff: st: Adding rows to datasheet
>
> Hi,
>
> This might seem like a no brainer to some of you.  I frequently run
> into the trouble where I need to add rows to a previous stata
> datasheet.  When I copy rows from excel and try to add to an existing
> stata datasheet, it seem to wipe off the header and replace it with
> the the newly added first row.  This happens even though I am adding
> data to say the 20th row.  The newly inserted row will always replace
> the header.  What am I doing wrong here?
>
> To explain it a bit better:  My header in stata reads--no. of
> patients, dead etc.  If I add an extra row from excel which has say
> 2345 and 2...this row deletes the header and the header will now read
> as 2345 and 2 instead of no. of patients, dead.
> thanks,
> Sripal.
> *
> *   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/
>

*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: AW: Adding rows to datasheet

Cohen, Elan
Have you tried increasing the number of observations first, then pasting your variables?

For instance, if you'd like to add one row, first type:

set obs `=_N+1'

then try pasting your data into the editor window.

- Elan
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Sripal Kumar
> Sent: Tuesday, March 23, 2010 10:07
> To: [hidden email]
> Subject: Re: st: AW: Adding rows to datasheet
>
> Can that be done for an entire row with say 25 variables
>
> On Tue, Mar 23, 2010 at 9:59 AM, Martin Weiss
> <[hidden email]> wrote:
> >
> > <>
> >
> > For a single row, you could also issue commands in the
> command window:
> >
> > *************
> > input
> > 232 453
> > end
> > *************
> >
> > assuming you have two variables in your dataset. This will
> append them to
> > the end of your dataset w/o altering anything else...
> >
> >
> > HTH
> > Martin
> >
> >
> > -----Ursprüngliche Nachricht-----
> > Von: [hidden email]
> > [mailto:[hidden email]] Im Auftrag
> von Sripal Kumar
> > Gesendet: Dienstag, 23. März 2010 14:48
> > An: statalist
> > Betreff: st: Adding rows to datasheet
> >
> > Hi,
> >
> > This might seem like a no brainer to some of you.  I frequently run
> > into the trouble where I need to add rows to a previous stata
> > datasheet.  When I copy rows from excel and try to add to
> an existing
> > stata datasheet, it seem to wipe off the header and replace it with
> > the the newly added first row.  This happens even though I am adding
> > data to say the 20th row.  The newly inserted row will
> always replace
> > the header.  What am I doing wrong here?
> >
> > To explain it a bit better:  My header in stata reads--no. of
> > patients, dead etc.  If I add an extra row from excel which has say
> > 2345 and 2...this row deletes the header and the header
> will now read
> > as 2345 and 2 instead of no. of patients, dead.
> > thanks,
> > Sripal.
> > *
> > *   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/
> >
>
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding rows to datasheet

Philipp Rehm
In reply to this post by Sripal Kumar
.
How about something like this:

sysuse auto, clear
set obs `=_N+1'
replace make="Made up" in l

I've learned this from one of Nick Cox' posts, some years (?) ago.

HTH,
Ph

On 3/23/2010 9:48 AM, Sripal Kumar wrote:

> Hi,
>
> This might seem like a no brainer to some of you.  I frequently run
> into the trouble where I need to add rows to a previous stata
> datasheet.  When I copy rows from excel and try to add to an existing
> stata datasheet, it seem to wipe off the header and replace it with
> the the newly added first row.  This happens even though I am adding
> data to say the 20th row.  The newly inserted row will always replace
> the header.  What am I doing wrong here?
>
> To explain it a bit better:  My header in stata reads--no. of
> patients, dead etc.  If I add an extra row from excel which has say
> 2345 and 2...this row deletes the header and the header will now read
> as 2345 and 2 instead of no. of patients, dead.
> thanks,
> Sripal.
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

AW: st: AW: Adding rows to datasheet

Martin Weiss-5
In reply to this post by Sripal Kumar

<>

Does work for 12 vars:

*************
sysuse auto, clear
inp
newcar 20000 43 3 4 14 3234 3 4 5 3 1
end
l in -2/l
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [hidden email]
[mailto:[hidden email]] Im Auftrag von Sripal Kumar
Gesendet: Dienstag, 23. März 2010 15:07
An: [hidden email]
Betreff: Re: st: AW: Adding rows to datasheet

Can that be done for an entire row with say 25 variables

On Tue, Mar 23, 2010 at 9:59 AM, Martin Weiss <[hidden email]> wrote:

>
> <>
>
> For a single row, you could also issue commands in the command window:
>
> *************
> input
> 232 453
> end
> *************
>
> assuming you have two variables in your dataset. This will append them to
> the end of your dataset w/o altering anything else...
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: [hidden email]
> [mailto:[hidden email]] Im Auftrag von Sripal Kumar
> Gesendet: Dienstag, 23. März 2010 14:48
> An: statalist
> Betreff: st: Adding rows to datasheet
>
> Hi,
>
> This might seem like a no brainer to some of you.  I frequently run
> into the trouble where I need to add rows to a previous stata
> datasheet.  When I copy rows from excel and try to add to an existing
> stata datasheet, it seem to wipe off the header and replace it with
> the the newly added first row.  This happens even though I am adding
> data to say the 20th row.  The newly inserted row will always replace
> the header.  What am I doing wrong here?
>
> To explain it a bit better:  My header in stata reads--no. of
> patients, dead etc.  If I add an extra row from excel which has say
> 2345 and 2...this row deletes the header and the header will now read
> as 2345 and 2 instead of no. of patients, dead.
> thanks,
> Sripal.
> *
> *   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/
>

*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AW: Adding rows to datasheet

Sripal Kumar
In reply to this post by Cohen, Elan
Tried set obs `=_N+1'.  It does create an extra row but when I use the
editor to paste into it, nothing pastes into that row. It goes to
replace the header!!!

On Tue, Mar 23, 2010 at 10:12 AM, Cohen, Elan <[hidden email]> wrote:

> Have you tried increasing the number of observations first, then pasting your variables?
>
> For instance, if you'd like to add one row, first type:
>
> set obs `=_N+1'
>
> then try pasting your data into the editor window.
>
> - Elan
>
>
>> -----Original Message-----
>> From: [hidden email]
>> [mailto:[hidden email]] On Behalf Of
>> Sripal Kumar
>> Sent: Tuesday, March 23, 2010 10:07
>> To: [hidden email]
>> Subject: Re: st: AW: Adding rows to datasheet
>>
>> Can that be done for an entire row with say 25 variables
>>
>> On Tue, Mar 23, 2010 at 9:59 AM, Martin Weiss
>> <[hidden email]> wrote:
>> >
>> > <>
>> >
>> > For a single row, you could also issue commands in the
>> command window:
>> >
>> > *************
>> > input
>> > 232 453
>> > end
>> > *************
>> >
>> > assuming you have two variables in your dataset. This will
>> append them to
>> > the end of your dataset w/o altering anything else...
>> >
>> >
>> > HTH
>> > Martin
>> >
>> >
>> > -----Ursprüngliche Nachricht-----
>> > Von: [hidden email]
>> > [mailto:[hidden email]] Im Auftrag
>> von Sripal Kumar
>> > Gesendet: Dienstag, 23. März 2010 14:48
>> > An: statalist
>> > Betreff: st: Adding rows to datasheet
>> >
>> > Hi,
>> >
>> > This might seem like a no brainer to some of you.  I frequently run
>> > into the trouble where I need to add rows to a previous stata
>> > datasheet.  When I copy rows from excel and try to add to
>> an existing
>> > stata datasheet, it seem to wipe off the header and replace it with
>> > the the newly added first row.  This happens even though I am adding
>> > data to say the 20th row.  The newly inserted row will
>> always replace
>> > the header.  What am I doing wrong here?
>> >
>> > To explain it a bit better:  My header in stata reads--no. of
>> > patients, dead etc.  If I add an extra row from excel which has say
>> > 2345 and 2...this row deletes the header and the header
>> will now read
>> > as 2345 and 2 instead of no. of patients, dead.
>> > thanks,
>> > Sripal.
>> > *
>> > *   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/
>> >
>>
>> *
>> *   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/
>

*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: AW: Adding rows to datasheet

Nick Cox
Stata doesn't have "headers". I don't know what you mean here, the first
observation or the variable information shown in the Editor.

I don't usually add extra rows -- Stata terminology is observations --by
copy and paste, but I just tried it from an application called MS Excel
which I found on my Windows machine.

1. Typed one observation with 1 2 3 into Stata Editor.

2. Typed one row with 3 4 5 into said MS Excel.

3. Copied that row and pasted it into new row in Editor. Worked fine.

No need for anything by way of -set obs-, which by the way I am sure I
didn't invent!

Nick
[hidden email]

Sripal Kumar

Tried set obs `=_N+1'.  It does create an extra row but when I use the
editor to paste into it, nothing pastes into that row. It goes to
replace the header!!!

On Tue, Mar 23, 2010 at 10:12 AM, Cohen, Elan <[hidden email]> wrote:
> Have you tried increasing the number of observations first, then
pasting your variables?
>
> For instance, if you'd like to add one row, first type:
>
> set obs `=_N+1'
>
> then try pasting your data into the editor window.


*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding rows to datasheet

Sripal Kumar
In reply to this post by Philipp Rehm
I tried that.  It works in the example you have give since the command
***replace make="Made up" in l** replaces the first column make with
made up.

If I have to replicate that I will have to use each header from a
database of 25 variables and say replace author with-- etc.  Isnt
there a simpler way?



On Tue, Mar 23, 2010 at 10:14 AM, Philipp Rehm <[hidden email]> wrote:

> .
> How about something like this:
>
> sysuse auto, clear
> set obs `=_N+1'
> replace make="Made up" in l
>
> I've learned this from one of Nick Cox' posts, some years (?) ago.
>
> HTH,
> Ph
>
> On 3/23/2010 9:48 AM, Sripal Kumar wrote:
>>
>> Hi,
>>
>> This might seem like a no brainer to some of you.  I frequently run
>> into the trouble where I need to add rows to a previous stata
>> datasheet.  When I copy rows from excel and try to add to an existing
>> stata datasheet, it seem to wipe off the header and replace it with
>> the the newly added first row.  This happens even though I am adding
>> data to say the 20th row.  The newly inserted row will always replace
>> the header.  What am I doing wrong here?
>>
>> To explain it a bit better:  My header in stata reads--no. of
>> patients, dead etc.  If I add an extra row from excel which has say
>> 2345 and 2...this row deletes the header and the header will now read
>> as 2345 and 2 instead of no. of patients, dead.
>> thanks,
>> Sripal.
>> *
>> *   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/
>

*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: AW: Adding rows to datasheet

Martin Weiss-5
In reply to this post by Nick Cox

<>

"
No need for anything by way of -set obs-, which by the way I am sure I
didn't invent!"



I guess Philipp was more concerned about the " `=_N+1' " part of the -set
obs- statement which he may have snapped up in your post:
http://www.stata.com/statalist/archive/2006-11/msg00222.html

HTH
Martin


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Nick Cox
Sent: Dienstag, 23. März 2010 21:00
To: [hidden email]
Subject: RE: st: AW: Adding rows to datasheet

Stata doesn't have "headers". I don't know what you mean here, the first
observation or the variable information shown in the Editor.

I don't usually add extra rows -- Stata terminology is observations --by
copy and paste, but I just tried it from an application called MS Excel
which I found on my Windows machine.

1. Typed one observation with 1 2 3 into Stata Editor.

2. Typed one row with 3 4 5 into said MS Excel.

3. Copied that row and pasted it into new row in Editor. Worked fine.

No need for anything by way of -set obs-, which by the way I am sure I
didn't invent!

Nick
[hidden email]

Sripal Kumar

Tried set obs `=_N+1'.  It does create an extra row but when I use the
editor to paste into it, nothing pastes into that row. It goes to
replace the header!!!

On Tue, Mar 23, 2010 at 10:12 AM, Cohen, Elan <[hidden email]> wrote:
> Have you tried increasing the number of observations first, then
pasting your variables?
>
> For instance, if you'd like to add one row, first type:
>
> set obs `=_N+1'
>
> then try pasting your data into the editor window.


*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: AW: Adding rows to datasheet

Nick Cox
Quite possibly, but I meant I didn't invent that example either.  

Nick
[hidden email]

Martin Weiss

"
No need for anything by way of -set obs-, which by the way I am sure I
didn't invent!"


I guess Philipp was more concerned about the " `=_N+1' " part of the
-set
obs- statement which he may have snapped up in your post:
http://www.stata.com/statalist/archive/2006-11/msg00222.html

Nick Cox

Stata doesn't have "headers". I don't know what you mean here, the first
observation or the variable information shown in the Editor.

I don't usually add extra rows -- Stata terminology is observations --by
copy and paste, but I just tried it from an application called MS Excel
which I found on my Windows machine.

1. Typed one observation with 1 2 3 into Stata Editor.

2. Typed one row with 3 4 5 into said MS Excel.

3. Copied that row and pasted it into new row in Editor. Worked fine.

No need for anything by way of -set obs-, which by the way I am sure I
didn't invent!

Nick
[hidden email]

Sripal Kumar

Tried set obs `=_N+1'.  It does create an extra row but when I use the
editor to paste into it, nothing pastes into that row. It goes to
replace the header!!!

On Tue, Mar 23, 2010 at 10:12 AM, Cohen, Elan <[hidden email]> wrote:
> Have you tried increasing the number of observations first, then
pasting your variables?
>
> For instance, if you'd like to add one row, first type:
>
> set obs `=_N+1'
>
> then try pasting your data into the editor window.

*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AW: Adding rows to datasheet

Sripal Kumar
In reply to this post by Nick Cox
Aha.  I see why you can do it and I cant.  Before that, yes--by header
I meant the variable information and not the observation.

I tried to do what you did and it works well.  But then I realized
thats because you used all numeric variables only.  Pls try this

1.  First observation in data editor of stata---Bell  2009 45  prospective
2.  Type:  stata 2010 100 retrospective --into excel and see if you
can paste it back into stata

When I tried to do this, it replaces the variable information with the
new row you paste.


On Tue, Mar 23, 2010 at 3:59 PM, Nick Cox <[hidden email]> wrote:

> Stata doesn't have "headers". I don't know what you mean here, the first
> observation or the variable information shown in the Editor.
>
> I don't usually add extra rows -- Stata terminology is observations --by
> copy and paste, but I just tried it from an application called MS Excel
> which I found on my Windows machine.
>
> 1. Typed one observation with 1 2 3 into Stata Editor.
>
> 2. Typed one row with 3 4 5 into said MS Excel.
>
> 3. Copied that row and pasted it into new row in Editor. Worked fine.
>
> No need for anything by way of -set obs-, which by the way I am sure I
> didn't invent!
>
> Nick
> [hidden email]
>
> Sripal Kumar
>
> Tried set obs `=_N+1'.  It does create an extra row but when I use the
> editor to paste into it, nothing pastes into that row. It goes to
> replace the header!!!
>
> On Tue, Mar 23, 2010 at 10:12 AM, Cohen, Elan <[hidden email]> wrote:
>> Have you tried increasing the number of observations first, then
> pasting your variables?
>>
>> For instance, if you'd like to add one row, first type:
>>
>> set obs `=_N+1'
>>
>> then try pasting your data into the editor window.
>
>
> *
> *   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding rows to datasheet

Eric A. Booth
In reply to this post by Sripal Kumar
>

Similar to others that have posted, I'm not having any issues simply copy/pasting extra rows from an Excel spreadsheet into an existing Stata dataset.
Since you are still having issues, I think a more straightforward solution is to save your excel file in a delimited format, -insheet- and save the data, and then -append- it to the data in memory.   (plus, you mention that you have to do this often, and this process is easy to repeat/automate).

~ Eric

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


On Mar 23, 2010, at 3:05 PM, Sripal Kumar wrote:

> I tried that.  It works in the example you have give since the command
> ***replace make="Made up" in l** replaces the first column make with
> made up.
>
> If I have to replicate that I will have to use each header from a
> database of 25 variables and say replace author with-- etc.  Isnt
> there a simpler way?
>
>
>
> On Tue, Mar 23, 2010 at 10:14 AM, Philipp Rehm <[hidden email]> wrote:
>> .
>> How about something like this:
>>
>> sysuse auto, clear
>> set obs `=_N+1'
>> replace make="Made up" in l
>>
>> I've learned this from one of Nick Cox' posts, some years (?) ago.
>>
>> HTH,
>> Ph
>>
>> On 3/23/2010 9:48 AM, Sripal Kumar wrote:
>>>
>>> Hi,
>>>
>>> This might seem like a no brainer to some of you.  I frequently run
>>> into the trouble where I need to add rows to a previous stata
>>> datasheet.  When I copy rows from excel and try to add to an existing
>>> stata datasheet, it seem to wipe off the header and replace it with
>>> the the newly added first row.  This happens even though I am adding
>>> data to say the 20th row.  The newly inserted row will always replace
>>> the header.  What am I doing wrong here?
>>>
>>> To explain it a bit better:  My header in stata reads--no. of
>>> patients, dead etc.  If I add an extra row from excel which has say
>>> 2345 and 2...this row deletes the header and the header will now read
>>> as 2345 and 2 instead of no. of patients, dead.
>>> thanks,
>>> Sripal.
>>> *



*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: AW: Adding rows to datasheet

Martin Weiss-5
In reply to this post by Sripal Kumar

<>

"1.  First observation in data editor of stata---Bell  2009 45  prospective
2.  Type:  stata 2010 100 retrospective --into excel and see if you
can paste it back into stata"



Yes, with this example, you are fully vindicated. Stata 10.1 does indeed
make the second row of data the variable names (which you called "header").
Stata 11 handles the same problem much more elegantly, and leaves the names
alone...


HTH
Martin


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Sripal Kumar
Sent: Dienstag, 23. März 2010 21:18
To: [hidden email]
Subject: Re: st: AW: Adding rows to datasheet

Aha.  I see why you can do it and I cant.  Before that, yes--by header
I meant the variable information and not the observation.

I tried to do what you did and it works well.  But then I realized
thats because you used all numeric variables only.  Pls try this

1.  First observation in data editor of stata---Bell  2009 45  prospective
2.  Type:  stata 2010 100 retrospective --into excel and see if you
can paste it back into stata

When I tried to do this, it replaces the variable information with the
new row you paste.


On Tue, Mar 23, 2010 at 3:59 PM, Nick Cox <[hidden email]> wrote:

> Stata doesn't have "headers". I don't know what you mean here, the first
> observation or the variable information shown in the Editor.
>
> I don't usually add extra rows -- Stata terminology is observations --by
> copy and paste, but I just tried it from an application called MS Excel
> which I found on my Windows machine.
>
> 1. Typed one observation with 1 2 3 into Stata Editor.
>
> 2. Typed one row with 3 4 5 into said MS Excel.
>
> 3. Copied that row and pasted it into new row in Editor. Worked fine.
>
> No need for anything by way of -set obs-, which by the way I am sure I
> didn't invent!
>
> Nick
> [hidden email]
>
> Sripal Kumar
>
> Tried set obs `=_N+1'.  It does create an extra row but when I use the
> editor to paste into it, nothing pastes into that row. It goes to
> replace the header!!!
>
> On Tue, Mar 23, 2010 at 10:12 AM, Cohen, Elan <[hidden email]> wrote:
>> Have you tried increasing the number of observations first, then
> pasting your variables?
>>
>> For instance, if you'd like to add one row, first type:
>>
>> set obs `=_N+1'
>>
>> then try pasting your data into the editor window.
>
>
> *
> *   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/


*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AW: Adding rows to datasheet

Eric A. Booth
In reply to this post by Sripal Kumar
>

Sripal:
I tried your example and it works for me--I can copy/paste into excel and back into Stata and it doesnt replace the variable names.
 
What version of Stata do you have? (I'm curious whether previous versions of Stata behave differently)

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



On Mar 23, 2010, at 3:17 PM, Sripal Kumar wrote:

> Aha.  I see why you can do it and I cant.  Before that, yes--by header
> I meant the variable information and not the observation.
>
> I tried to do what you did and it works well.  But then I realized
> thats because you used all numeric variables only.  Pls try this
>
> 1.  First observation in data editor of stata---Bell  2009 45  prospective
> 2.  Type:  stata 2010 100 retrospective --into excel and see if you
> can paste it back into stata
>
> When I tried to do this, it replaces the variable information with the
> new row you paste.
>
>
> On Tue, Mar 23, 2010 at 3:59 PM, Nick Cox <[hidden email]> wrote:
>> Stata doesn't have "headers". I don't know what you mean here, the first
>> observation or the variable information shown in the Editor.
>>
>> I don't usually add extra rows -- Stata terminology is observations --by
>> copy and paste, but I just tried it from an application called MS Excel
>> which I found on my Windows machine.
>>
>> 1. Typed one observation with 1 2 3 into Stata Editor.
>>
>> 2. Typed one row with 3 4 5 into said MS Excel.
>>
>> 3. Copied that row and pasted it into new row in Editor. Worked fine.
>>
>> No need for anything by way of -set obs-, which by the way I am sure I
>> didn't invent!
>>
>> Nick
>> [hidden email]
>>
>> Sripal Kumar
>>
>> Tried set obs `=_N+1'.  It does create an extra row but when I use the
>> editor to paste into it, nothing pastes into that row. It goes to
>> replace the header!!!
>>
>> On Tue, Mar 23, 2010 at 10:12 AM, Cohen, Elan <[hidden email]> wrote:
>>> Have you tried increasing the number of observations first, then
>> pasting your variables?
>>>
>>> For instance, if you'd like to add one row, first type:
>>>
>>> set obs `=_N+1'
>>>
>>> then try pasting your data into the editor window.
>>
>>
>>

*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: AW: Adding rows to datasheet

Martin Weiss-5

<>

" What version of Stata do you have?"



Everything said here is for Stata 10.1...


HTH
Martin


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Eric Booth
Sent: Dienstag, 23. März 2010 21:26
To: [hidden email]
Subject: Re: st: AW: Adding rows to datasheet

>

Sripal:
I tried your example and it works for me--I can copy/paste into excel and
back into Stata and it doesnt replace the variable names.
 
What version of Stata do you have? (I'm curious whether previous versions of
Stata behave differently)

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



On Mar 23, 2010, at 3:17 PM, Sripal Kumar wrote:

> Aha.  I see why you can do it and I cant.  Before that, yes--by header
> I meant the variable information and not the observation.
>
> I tried to do what you did and it works well.  But then I realized
> thats because you used all numeric variables only.  Pls try this
>
> 1.  First observation in data editor of stata---Bell  2009 45  prospective
> 2.  Type:  stata 2010 100 retrospective --into excel and see if you
> can paste it back into stata
>
> When I tried to do this, it replaces the variable information with the
> new row you paste.
>
>
> On Tue, Mar 23, 2010 at 3:59 PM, Nick Cox <[hidden email]> wrote:
>> Stata doesn't have "headers". I don't know what you mean here, the first
>> observation or the variable information shown in the Editor.
>>
>> I don't usually add extra rows -- Stata terminology is observations --by
>> copy and paste, but I just tried it from an application called MS Excel
>> which I found on my Windows machine.
>>
>> 1. Typed one observation with 1 2 3 into Stata Editor.
>>
>> 2. Typed one row with 3 4 5 into said MS Excel.
>>
>> 3. Copied that row and pasted it into new row in Editor. Worked fine.
>>
>> No need for anything by way of -set obs-, which by the way I am sure I
>> didn't invent!
>>
>> Nick
>> [hidden email]
>>
>> Sripal Kumar
>>
>> Tried set obs `=_N+1'.  It does create an extra row but when I use the
>> editor to paste into it, nothing pastes into that row. It goes to
>> replace the header!!!
>>
>> On Tue, Mar 23, 2010 at 10:12 AM, Cohen, Elan <[hidden email]> wrote:
>>> Have you tried increasing the number of observations first, then
>> pasting your variables?
>>>
>>> For instance, if you'd like to add one row, first type:
>>>
>>> set obs `=_N+1'
>>>
>>> then try pasting your data into the editor window.
>>
>>
>>

*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: AW: Adding rows to datasheet

Martin Weiss-5
In reply to this post by Martin Weiss-5

<>

" Stata 10.1 does indeed
make the second row of data the variable names"

Or rather: It rechristens the first variable as "stata", and the other two
(numeric) ones as "var1"/"var2". "2010" and "100" suddenly become the -var
labels- of these two variables. End result:


. d

Contains data
  obs:             1                          
 vars:             3                          
 size:            36 (99.9% of memory free)
----------------------------------------------------------------------------
--------------------
              storage  display     value
variable name   type   format      label      variable label
----------------------------------------------------------------------------
--------------------
stata           str20  %20s                  
var1            float  %9.0g                  2010
var2            float  %9.0g                  100
----------------------------------------------------------------------------
--------------------
Sorted by:  
     Note:  dataset has changed since last saved

 

This must have something to do with the fact that you are pasting into a
mixture of string and numeric variables...


HTH
Martin


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Martin Weiss
Sent: Dienstag, 23. März 2010 21:23
To: [hidden email]
Subject: RE: st: AW: Adding rows to datasheet


<>

"1.  First observation in data editor of stata---Bell  2009 45  prospective
2.  Type:  stata 2010 100 retrospective --into excel and see if you
can paste it back into stata"



Yes, with this example, you are fully vindicated. Stata 10.1 does indeed
make the second row of data the variable names (which you called "header").
Stata 11 handles the same problem much more elegantly, and leaves the names
alone...


HTH
Martin


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Sripal Kumar
Sent: Dienstag, 23. März 2010 21:18
To: [hidden email]
Subject: Re: st: AW: Adding rows to datasheet

Aha.  I see why you can do it and I cant.  Before that, yes--by header
I meant the variable information and not the observation.

I tried to do what you did and it works well.  But then I realized
thats because you used all numeric variables only.  Pls try this

1.  First observation in data editor of stata---Bell  2009 45  prospective
2.  Type:  stata 2010 100 retrospective --into excel and see if you
can paste it back into stata

When I tried to do this, it replaces the variable information with the
new row you paste.


On Tue, Mar 23, 2010 at 3:59 PM, Nick Cox <[hidden email]> wrote:

> Stata doesn't have "headers". I don't know what you mean here, the first
> observation or the variable information shown in the Editor.
>
> I don't usually add extra rows -- Stata terminology is observations --by
> copy and paste, but I just tried it from an application called MS Excel
> which I found on my Windows machine.
>
> 1. Typed one observation with 1 2 3 into Stata Editor.
>
> 2. Typed one row with 3 4 5 into said MS Excel.
>
> 3. Copied that row and pasted it into new row in Editor. Worked fine.
>
> No need for anything by way of -set obs-, which by the way I am sure I
> didn't invent!
>
> Nick
> [hidden email]
>
> Sripal Kumar
>
> Tried set obs `=_N+1'.  It does create an extra row but when I use the
> editor to paste into it, nothing pastes into that row. It goes to
> replace the header!!!
>
> On Tue, Mar 23, 2010 at 10:12 AM, Cohen, Elan <[hidden email]> wrote:
>> Have you tried increasing the number of observations first, then
> pasting your variables?
>>
>> For instance, if you'd like to add one row, first type:
>>
>> set obs `=_N+1'
>>
>> then try pasting your data into the editor window.
>
>
> *
> *   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/


*
*   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/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AW: Adding rows to datasheet

Sripal Kumar
In reply to this post by Sripal Kumar
I am glad that I was able to atleast convey the problem..though it
doesnt look like there is a simple solution.

On Tue, Mar 23, 2010 at 4:22 PM, Martin Weiss <[hidden email]> wrote:

>
> <>
>
> "1.  First observation in data editor of stata---Bell  2009 45  prospective
> 2.  Type:  stata 2010 100 retrospective --into excel and see if you
> can paste it back into stata"
>
>
>
> Yes, with this example, you are fully vindicated. Stata 10.1 does indeed
> make the second row of data the variable names (which you called "header").
> Stata 11 handles the same problem much more elegantly, and leaves the names
> alone...
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Sripal Kumar
> Sent: Dienstag, 23. März 2010 21:18
> To: [hidden email]
> Subject: Re: st: AW: Adding rows to datasheet
>
> Aha.  I see why you can do it and I cant.  Before that, yes--by header
> I meant the variable information and not the observation.
>
> I tried to do what you did and it works well.  But then I realized
> thats because you used all numeric variables only.  Pls try this
>
> 1.  First observation in data editor of stata---Bell  2009 45  prospective
> 2.  Type:  stata 2010 100 retrospective --into excel and see if you
> can paste it back into stata
>
> When I tried to do this, it replaces the variable information with the
> new row you paste.
>
>
> On Tue, Mar 23, 2010 at 3:59 PM, Nick Cox <[hidden email]> wrote:
>> Stata doesn't have "headers". I don't know what you mean here, the first
>> observation or the variable information shown in the Editor.
>>
>> I don't usually add extra rows -- Stata terminology is observations --by
>> copy and paste, but I just tried it from an application called MS Excel
>> which I found on my Windows machine.
>>
>> 1. Typed one observation with 1 2 3 into Stata Editor.
>>
>> 2. Typed one row with 3 4 5 into said MS Excel.
>>
>> 3. Copied that row and pasted it into new row in Editor. Worked fine.
>>
>> No need for anything by way of -set obs-, which by the way I am sure I
>> didn't invent!
>>
>> Nick
>> [hidden email]
>>
>> Sripal Kumar
>>
>> Tried set obs `=_N+1'.  It does create an extra row but when I use the
>> editor to paste into it, nothing pastes into that row. It goes to
>> replace the header!!!
>>
>> On Tue, Mar 23, 2010 at 10:12 AM, Cohen, Elan <[hidden email]> wrote:
>>> Have you tried increasing the number of observations first, then
>> pasting your variables?
>>>
>>> For instance, if you'd like to add one row, first type:
>>>
>>> set obs `=_N+1'
>>>
>>> then try pasting your data into the editor window.
>>
>>
>> *
>> *   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/
>
>
> *
> *   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/
Loading...