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

Syntax to Generate Missing Data in Data Lines

9 views
Skip to first unread message

Denise

unread,
Feb 3, 2010, 11:40:07 AM2/3/10
to
Hello,

I'm not sure if this is possible to carry out in SPSS, but I thought I
would check just in case.

Basically I have a file that has health care data for patients that
includes the encounter id (unique identifier for the health care
encounter), medical record number (unique identifier for the patient),
and a list of primary & secondary diagnoses (if applicable). However,
in the file I have the diagnoses are listed below the data line that
contain the encounter id and medical record number, so there is no way
of linking these diagnoses back to the patient.
I am wondering if any syntax exists to generate missing data when data
files are set up like this?

Here is an example of the file:

Encounter ID Medical Record Number Primary/Secondary Diagnosis
2001 0001
open wound
fall
2003 0002
sprain
abrasion
fall
depression

Any feedback is greatly appreciated.

Many thanks,

Denise

Bruce Weaver

unread,
Feb 3, 2010, 11:50:39 AM2/3/10
to

Look up the LAG function in the Help files. If the encounter id
variable is numeric, you can use the MISSING function, something like
this:

do if missing(encounter_id).
- compute encounter_id = LAG(encounter_id).
- compute mrn = LAG(mrn).
end if.

But if it's a string variable, MISSING won't work, and you'll have to
do something like:

do if (encounter_id EQ "").
- compute encounter_id = LAG(encounter_id).
- compute mrn = LAG(mrn).
end if.

Should you then want to move all the data for an encounter to a single
row (which may be necessary for some analyses), look up CASESTOVARS.

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

Denise

unread,
Feb 3, 2010, 2:31:19 PM2/3/10
to
Dear Bruce,

This is amazing, it has completely fixed my file. I am so happy!

Many thanks for your kind help,

Best,

Denise

> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/Home

Rich Ulrich

unread,
Feb 3, 2010, 2:49:43 PM2/3/10
to

Something like that is needed if the data are already in an SPSS
file with all those ID fields missing.

But it otherwise looks like an application that calls for Input
Record definitions. It would be easier for Input Record to
deal with multiple lines of followup (I think) if the lines of a case
were numbered in a unique column.

--
Rich Ulrich

Bruce Weaver

unread,
Feb 3, 2010, 4:47:25 PM2/3/10
to
On Feb 3, 2:31 pm, Denise <mcfadden.den...@gmail.com> wrote:
> Dear Bruce,
>
> This is amazing, it has completely fixed my file. I am so happy!
>
> Many thanks for your kind help,
>
> Best,
>
> Denise


And I got quite a kick out of your enthusiastic reaction, so I'd say
we're even. ;-)

--
Bruce Weaver
bwe...@lakeheadu.ca

Denise

unread,
Feb 3, 2010, 4:53:30 PM2/3/10
to
On Feb 3, 4:47 pm, Bruce Weaver <bwea...@lakeheadu.ca> wrote:
> On Feb 3, 2:31 pm, Denise <mcfadden.den...@gmail.com> wrote:
>
> > Dear Bruce,
>
> > This is amazing, it has completely fixed my file. I am so happy!
>
> > Many thanks for your kind help,
>
> > Best,
>
> > Denise
>
> And I got quite a kick out of your enthusiastic reaction, so I'd say
> we're even.  ;-)
>
> --
> Bruce Weaver
> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/Home

> "When all else fails, RTFM."

:) I mean it! You have saved the day.

Bruce Weaver

unread,
Feb 3, 2010, 5:29:11 PM2/3/10
to

Quite right, Rich. I wondered if the data file arose from using MATCH
FILES with /FILE where /TABLE should have been used. Several years
ago, before I knew about that distinction, I often ended up with data
files like the one Denise described, and used LAG to fill in data on
rows where it was missing. Later, when I did learn about /TABLE, I
immediately thought about how much time and effort I could have saved
if I'd know that sooner! ;-)

Denise, if you did arrive at that data file format via MATCH FILES,
look at the one-to-many merging example here:

http://www.ats.ucla.edu/stat/spss/modules/merge.htm

fred....@lsc.gov.uk

unread,
Feb 4, 2010, 4:02:31 AM2/4/10
to
Aahh, Super Bruce to the rescue, I for one shall sleep easier tonight
knowing that Bruce is out there protecting us all

;-)

On Feb 3, 9:47 pm, Bruce Weaver <bwea...@lakeheadu.ca> wrote:
> On Feb 3, 2:31 pm, Denise <mcfadden.den...@gmail.com> wrote:
>
> > Dear Bruce,
>
> > This is amazing, it has completely fixed my file. I am so happy!
>
> > Many thanks for your kind help,
>
> > Best,
>
> > Denise
>
> And I got quite a kick out of your enthusiastic reaction, so I'd say
> we're even.  ;-)
>
> --
> Bruce Weaver

> bwea...@lakeheadu.cahttp://sites.google.com/a/lakeheadu.ca/bweaver/Home

Bruce Weaver

unread,
Feb 4, 2010, 7:13:06 AM2/4/10
to
Thanks Fred...I needed a good laugh to start my day. ;-)
0 new messages