Fill in empty rows

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Fill in empty rows

DEBOER
Hi all,

I have a problem. I want to fill in the rows.

e.g I have a data set as follow:

Name                 works       hours

Ronny                 20             6
                         10             2
                         30             8

Elin                     20            5
                          10           1
Kate                    25            5


Anneli                  40           10
                          23            8
                          59            30


I would like a syntax that can creates that I got all names filled in at the name row as  

Ronny                 20             6
Ronny                 10             2
Ronny                  30             8
Elin                     20            5
Elin                     10           1
Kate                    25            5
Anneli                  40           10
Anneli                  23            8
Anneli                  59            30    


Thanks in advance  

Reply | Threaded
Open this post in threaded view
|

Re: Fill in empty rows

David Marso
Administrator
See LAG!
--
DEBOER wrote
Hi all,

I have a problem. I want to fill in the rows.

e.g I have a data set as follow:

Name                 works       hours

Ronny                 20             6
                         10             2
                         30             8

Elin                     20            5
                          10           1
Kate                    25            5


Anneli                  40           10
                          23            8
                          59            30


I would like a syntax that can creates that I got all names filled in at the name row as  

Ronny                 20             6
Ronny                 10             2
Ronny                  30             8
Elin                     20            5
Elin                     10           1
Kate                    25            5
Anneli                  40           10
Anneli                  23            8
Anneli                  59            30    


Thanks in advance
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Fill in empty rows

Jim Marks
In reply to this post by DEBOER

A scratch variable will do this for you:

* sample data.
NEW FILE.
DATA LIST LIST /name (a10) works (f8.0) hours (f8.0).
BEGIN DATA
Ronny, 20 ,6
 ,10, 2
 ,30, 8
Elin, 20, 5
 ,10 , 1
Kate, 25 , 5
Anneli, 40 , 10
 , 23 , 8
 , 59, 30
END DATA.

LIST.

STRING #nameit (a10).
DO IF LENGTH (RTRIM (name)) GT 0.
COMPUTE #nameit = name.
ELSE.
COMPUTE name EQ #nameit.
END IF.

LIST.



Jim Marks
Sr Market Research Manager
National Market Research
Kaiser Foundation Health Plan of the Mid-Atlantic States, Inc.
2101 E. Jefferson St.
Rockville, MD 20852
Phone: (301) 816-6822
Cell Phone: (301) 456-6164

NOTICE TO RECIPIENT:  If you are not the intended recipient of this e-mail, you are prohibited from sharing, copying, or otherwise using or disclosing its contents.  If you have received this e-mail in error, please notify the sender immediately by reply e-mail and permanently delete this e-mail and any attachments without reading, forwarding or saving them.  Thank you.




From:        DEBOER <[hidden email]>
To:        [hidden email]
Date:        05/31/2013 07:04 PM
Subject:        Fill in empty rows
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hi all,

I have a problem. I want to fill in the rows.

e.g I have a data set as follow:

Name                 works       hours

Ronny                 20             6
                        10             2
                        30             8

Elin                     20            5
                         10           1
Kate                    25            5


Anneli                  40           10
                         23            8
                         59            30


I would like a syntax that can creates that I got all names filled in at the
name row as

Ronny                 20             6
Ronny                 10             2
Ronny                  30             8
Elin                     20            5
Elin                     10           1
Kate                    25            5
Anneli                  40           10
Anneli                  23            8
Anneli                  59            30


Thanks in advance





--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Fill-in-empty-rows-tp5720515.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

Reply | Threaded
Open this post in threaded view
|

Re: Fill in empty rows

Bruce Weaver
Administrator
Jim, why not just do this?

IF name EQ "" name = LAG(name).
LIST.

Or if you have reason to think RTRIM is needed:

IF RTRIM(name) EQ "" name = LAG(name).
LIST.

There are a lot fewer keystrokes, and I think it's more transparent (especially for novice users).



Jim Marks wrote
A scratch variable will do this for you:

* sample data.
NEW FILE.
DATA LIST LIST /name (a10) works (f8.0) hours (f8.0).
BEGIN DATA
Ronny, 20 ,6
 ,10, 2
 ,30, 8
Elin, 20, 5
 ,10 , 1
Kate, 25 , 5
Anneli, 40 , 10
 , 23 , 8
 , 59, 30
END DATA.

LIST.

STRING #nameit (a10).
DO IF LENGTH (RTRIM (name)) GT 0.
COMPUTE #nameit = name.
ELSE.
COMPUTE name EQ #nameit.
END IF.

LIST.



Jim Marks
Sr Market Research Manager
National Market Research
Kaiser Foundation Health Plan of the Mid-Atlantic States, Inc.
2101 E. Jefferson St.
Rockville, MD 20852
Phone: (301) 816-6822
Cell Phone: (301) 456-6164

NOTICE TO RECIPIENT:  If you are not the intended recipient of this
e-mail, you are prohibited from sharing, copying, or otherwise using or
disclosing its contents.  If you have received this e-mail in error,
please notify the sender immediately by reply e-mail and permanently
delete this e-mail and any attachments without reading, forwarding or
saving them.  Thank you.




From:   DEBOER <[hidden email]>
To:     [hidden email]
Date:   05/31/2013 07:04 PM
Subject:        Fill in empty rows
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



Hi all,

I have a problem. I want to fill in the rows.

e.g I have a data set as follow:

Name                 works       hours

Ronny                 20             6
                         10             2
                         30             8

Elin                     20            5
                          10           1
Kate                    25            5


Anneli                  40           10
                          23            8
                          59            30


I would like a syntax that can creates that I got all names filled in at
the
name row as

Ronny                 20             6
Ronny                 10             2
Ronny                  30             8
Elin                     20            5
Elin                     10           1
Kate                    25            5
Anneli                  40           10
Anneli                  23            8
Anneli                  59            30


Thanks in advance





--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Fill-in-empty-rows-tp5720515.html

Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).