Create New Variable with Different Values Using Syntax

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

ken_Vasteras
Posts: 2
Joined: Tue Mar 19, 2013 7:14 pm

Create New Variable with Different Values Using Syntax

Postby ken_Vasteras » Tue Mar 19, 2013 7:57 pm

I have a large dataset with 500,000 rows. I need to create a new variable called "class". The IDs can have a different value under the "class" variable. Some IDs will have the same value under the "class" variable. It is illustrated below. I will appreciate help on this.

Old:
ID Student
1 John
2 Mary
3 Kate
4 Jones

New:
ID Student Class
1 John 2011
2 Mary 2012
3 Kate 2013
4 Jones 2013
statman
Administrator
Posts: 2737
Joined: Tue Jun 12, 2007 12:08 pm
Location: Florida, USA

Re: Create New Variable with Different Values Using Syntax

Postby statman » Wed Mar 20, 2013 2:48 pm

Where does the date come from?

So you want to append the date?
See the note below

NOTE: Please read the Posting Guidelines and always tell us your OS, the SPSS version and information about your study and data!

Statman
Statistical Services
ken_Vasteras
Posts: 2
Joined: Tue Mar 19, 2013 7:14 pm

Re: Create New Variable with Different Values Using Syntax

Postby ken_Vasteras » Wed Mar 20, 2013 9:52 pm

I have 500,000 cases need to append the year to each of them. The information on the year is in hard copy. Thankfully, there are only five years: 2009 - 2013. There will be about 100,000 cases for each year. I tried this with some success:

DO IF(ID=1).
COMPUTE YEAR=2009.
END IF.

I say "some success" because using this strategy, I have to write a syntax for each case, which is too tedious. Is there a way to specify a range like:

DO IF(1D=1 through 100000)
COMPUTE YEAR=2009
END IF.

I am pretty sure "through" is not a spss command. I apologize for my ignorance.

-Ken

Who is online

Users browsing this forum: No registered users and 2 guests

cron