Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Restructure dataset to create unique cases

10 views
Skip to first unread message

Kurt Heisler

unread,
Dec 12, 2009, 10:53:19 PM12/12/09
to
I have a dataset that looks like this:

Dept Count Title Function
ABC 2 Office Worker 3rd Floor
ABC 1 Office Worker 1st Floor
ABC 2 Non-Office Worker 3rd Floor
ABC 2 Non-Office Worker 1st Floor
XYZ 5 Office Worker 3rd Floor
XYZ 7 Office Worker 2nd Floor
etc.

For instance, the first record tells me that Dept ABC has 2 Office
Workers on the 3rd floor.

I need to restructure the dataset so each person gets his own row/
record. For instance, the first record would become two records:

ABC 1 Office Worker 3rd Floor
ABC 1 Office Worker 3rd Floor

In this case, I don’t really need to keep the count variable.

Any suggestions how to restructure this with syntax? I’m not even sure
where to start.

Thank you.

Ben Pfaff

unread,
Dec 12, 2009, 11:14:25 PM12/12/09
to
Kurt Heisler <heisl...@gmail.com> writes:

> I have a dataset that looks like this:
>
> Dept Count Title Function
> ABC 2 Office Worker 3rd Floor
> ABC 1 Office Worker 1st Floor
> ABC 2 Non-Office Worker 3rd Floor
> ABC 2 Non-Office Worker 1st Floor
> XYZ 5 Office Worker 3rd Floor
> XYZ 7 Office Worker 2nd Floor
> etc.
>
> For instance, the first record tells me that Dept ABC has 2 Office
> Workers on the 3rd floor.
>
> I need to restructure the dataset so each person gets his own row/
> record. For instance, the first record would become two records:
>
> ABC 1 Office Worker 3rd Floor
> ABC 1 Office Worker 3rd Floor

Have you considered just weighting by the count variable?
--
Ben Pfaff
http://benpfaff.org

Kurt Heisler

unread,
Dec 13, 2009, 12:03:14 AM12/13/09
to
On Dec 12, 11:14 pm, Ben Pfaff <b...@cs.stanford.edu> wrote:

I need to assign a random number to each individual worker. This
requires that each person be on his own row.

Bruce Weaver

unread,
Dec 13, 2009, 9:29:56 AM12/13/09
to

I don't have SPSS on this machine, so the following is untested.

LOOP #i = 1 to count.
- xsave outfile = "C:\temp\one_record_per_person.sav" /
keep = dept title function.
END LOOP.
exe.

Now open the new file and compute your random number.

--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/
"When all else fails, RTFM."

Rich Ulrich

unread,
Dec 13, 2009, 4:27:41 PM12/13/09
to

At the same time as saving this first file, I think that
I would save a counter for within-the-department, and
probably the Random number, if that is going to be the
unique case ID. Modifying Bruce's --

LOOP DeptID = 1 to count.
compute RandID = < whatever > .


- xsave outfile = "C:\temp\one_record_per_person.sav" /

keep = dept title function DeptID RandID
END LOOP.
exe.

--
Rich Ulrich

0 new messages