How to Create Dummy Cases

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

Lomi
Posts: 1
Joined: Tue Sep 27, 2011 12:20 pm

How to Create Dummy Cases

Postby Lomi » Tue Sep 27, 2011 12:43 pm

Hello, I am new to this forum and have programming question I hope someone can help with.

I would like to automate one of my projects at work though I am not sure how to set up some of the code to automate it. What I need this for is to create consistent data so i can export each ID case to excel to link to graphs.

My question, is it possible to set up spss syntax to automatically create dummy cases? I use data provided to me quarterly from several institutions and new institutions join the project frequently. Each institutions is identified by a unique ID code and each quarter is tagged along with the associated year. When new institutions joins, they do not retroactively submit data, so I need to create dummy cases for each of the quarters that they did not report.

Example:
ID Year Quarter X1...Xn
1 2010 110
1 2010 210
1 2010 310
2 2011 110
2 2010 210
2 2010 310
2 2010 410
2 2010 111
2 2011 211
3 2010 410
3 2011 111
3 2011 212
4 2011 211

So in my example I have four institutions and data from First Quarter 2010 to Second Quarter 2011. How would I use syntax to create cases for the missing quarters for each id number (for ID 4 that would first quarter 2010 to first quarter 2011)? I have studied some very basic Python in the past and have a general feel for how it could work, though I am not sure how I could do it in SPSS.

From my understanding of Python, (which can be used along with SPSS syntax correct?) it would be possible to have a function create a list of all of the unique ID codes (so 1, 2, 3, 4) and then run a routine where it systematically determines if there is a case which has all three variables (ID (1-4), year (2010-2011), and quarter(110-211) for each valid combination and if there is not a case to create new case with just those three variables in it. I would assume that i would have to specify what each valid combination would be and each quarter I would have to go in and update the code to reflect the new quarter. My feeling is that it the routine would select ID 1 and then check if there is a case with ID 1, year 2010 and Quarter 110 and if not create one and then go to year 2010 and quarter 2010, etc.

Any help or resources anyone could provide would be greatly appreciated. Please let me know if you have any questions for me or if my question is confusing to you :-)

Thanks!
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: How to Create Dummy Cases

Postby GerineL » Tue Sep 27, 2011 2:55 pm

I don't know, but I'd like to hear the answer as well!

I use excel for this, but I don't need to change it every time so it is easier...

Who is online

Users browsing this forum: No registered users and 1 guest

cron