Thank you again, Rick!
Hopefully one more question for you:
I have created my final data file with 100 weeks of data per patient and 600+ patients. Within the set, we have a variable of "alert" (0 = no alert, 1 = alert) where the pt has alerted their medical team. We are trying to understand the symptoms 2 weeks leading up to an alert, the week of the alert itself, and the two weeks after the alert. If they have data for weeks 1,2,3,4,5 and alert on week 3, in the line for week 5, we have pulled forward all the data from each week to have five weeks of data in one line (weeks 1,2,3,4,5 symptoms are now all in week 5's line).
Where I'm struggling now is, I need to create a variable that takes each line, looks back two weeks to see if there was an alert, and if so, create a new variable, "AlertVector." While I have a separate variable telling me if each
individual week alerted, I don't know how to tell SPSS to take each line, check two weeks before, and IF they alerted two weeks prior, code AlertVector as a "1," and if there was
no alert two weeks prior, code as a "0." In some cases, that might be weeks 1,2,3(alert),4,5; in others it may be weeks 15,16,17(alert),18,19.
It seems simple-ish, but syntax keeps yelling at me.
Thanks in advance, Rick! Have a nice wknd!
EB
------------------------------
emily bmn
------------------------------
Original Message:
Sent: Fri June 10, 2022 01:39 PM
From: Rick Marcantonio
Subject: Adding New Cases via Syntax
Hi, Emily. Here is an example that might help.
** First, both files must be sorted by ID and WEEK.GET FILE TemplateFileNameHere.SORT CASES BY ID (A) WEEK (A).DATASET NAME Template.GET FILE OriginalFileNameHere.SORT CASES BY ID (A) WEEK (A).DATASET NAME Original.** Then, match them.MATCH FILES /FILE=Template /FILE=Original /IN=FromOriginalFile /BY ID WEEK.
At least now you have a binary variable (FromOriginalFile) telling you which row came from which dataset (1 if from the original file, 0 if from the template).
You can always discard cases with no ID.
SELECT IF NOT(MISSING(ID)).EXECUTE.
------------------------------
Rick Marcantonio
Quality Assurance
IBM
------------------------------
Original Message:
Sent: Fri June 10, 2022 01:18 PM
From: emily bmn
Subject: Adding New Cases via Syntax
Thank you for your help, Rick! I had read that was probably the best route to go, so it was nice to hear that supported.
I created a dataset for 600 P's, and 60 weeks per patient. The strange thing that's happening now, is I need to merge the "Original" dataset with the "Template" dataset based on their ID number and week number, but when I go to merge, it creates about 30 rows of empty cases (they have no ID number, but they have a week number, and I have no idea where they came from and if they have messed with the rest of the data).
I've searched high and low why this may be happening, and I can't get it to stop. Do you happen to have a syntax that tells SPSS to merge on two variables (ID and WEEK), merging the "Original" into the "Template?" Thanks!
------------------------------
emily bmn
Original Message:
Sent: Thu June 02, 2022 12:39 PM
From: Rick Marcantonio
Subject: Adding New Cases via Syntax
Hi, Emily.
If the number of weeks is known (say, 14), and there must be 14 rows for each patient, then I would set up a "dummy" dataset with nothing but a patient number and week number. 6000 rows in all, 2 variables only, no missing data.
Then I'd use the MATCH FILES procedure and match that dataset to the one with missing data(also sorted by patient and week).
If you want an example I will code and send one.
------------------------------
Rick Marcantonio
Quality Assurance
IBM