## Creating counting variable in huge dataset

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

wik999
Posts: 2
Joined: Thu Nov 13, 2014 2:56 am

### Creating counting variable in huge dataset

Hi there,

I'm having difficulties creating a count variable in my dataset. I want to create a variable that is counting the total numbers of years each subsidiary (subid) has existed. As shown by VAR00001, this is done for seq = 1713, giving 5 as output. Thus, I need this done for all of my subsidiaries (each subsidiary is given a number, as shown in the seq variable).

For example, for subsidiary 1491, I need SPSS to give me an output of 7 in each of the cells (row 6 - 12).

http://postimg.org/image/uonit15xx/

Sorry for not being able to upload a better picture. But just click the link.

Appreciate all help!

All best
Wik
statman
Posts: 2756
Joined: Tue Jun 12, 2007 12:08 pm
Location: Florida, USA

### Re: Creating counting variable in huge dataset

Sorry but no idea what you are talking about?
See the note below

Statman
Statistical Services
wik999
Posts: 2
Joined: Thu Nov 13, 2014 2:56 am

### Re: Creating counting variable in huge dataset

Okay, will try to explain a bit better. Its easier to understand if you copy this link into your clipboard: http://postimg.org/image/uonit15xx/

So the data is sorted after the variables seq and year. Hence, the seq (random number for a firm) has observations over year. For example, firm 1713 is followed from year 1999 - 2003 (as shown in the year column).

I now what to create a new variable (VAR00001) that is counting the total years each firm has existed. I have finger punched this for firm 1713, showing 5 years in each row.

Hence, for firm 1491, I need a syntax that will assign the value 7 in each row from 6-12 in the VAR00001 column.

Hope this explained it a little bit better. Are you able to open the link to the SPSS picture of my dataset?
Thanks you so much for any help!
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

### Re: Creating counting variable in huge dataset

you can do this via lag function or:
compute temp=1.
execute.

aggregate
/outfile = * mode = addvaraibles
/break=seq
/count=sum(temp).

delete variables temp.

### Who is online

Users browsing this forum: No registered users and 2 guests