Capture information of existing variables in new variables

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Capture information of existing variables in new variables

Javier Figueroa
Good afternoon, group of experts with the SPSS program

I have a problem that I have not been able to solve and I would like you to help me.

In my possession I have a database which includes 384 variables (var1 to var384) and I need to go through all the variables and leave the first 5 consecutive answers, besides showing a list of possible repeated codes (errors), I have this syntax and It works a bit, I could not get the codes to leave them consecutively, where there is 0 to omit and put the next one. ex. exists in the original base var1 = 0, var2 = 1, var3 = 3, var4 = 384, var5 = 200, var6 = 0, var7 = 0, var8 = 0, var9 = 5 and I want the base to be with new variables var_new1 = 1, var_new2 = 3, var_new3 = 384, var_new4 = 200, var_new5 = 5. Any comments and / or help I will be very grateful

This is the code or syntax that I generated.


data list list
/var1 to var384.
begin data.
1 1 5 150 0 0 0 0 15 20
3 1 3 180 50 35 0 80 0 35
5 3 4 350 0 384 35 30 0 80
6 4 5 80 80 0 35 384 200 350
7 5 3 200 0 50 30 0 200 1
8 3 280 25 0 0 50 10 2 3
5 5 35 5 0 10 15 0 5 10
6 7 40 384 66 0 0 0 100 384
7 2 50 35 80 35 340 200 0 1
8 2 80 50 0 0 384 100 1 25
9 5 5 40 0 0 0 0 311 250
10 2 20 15 384 0 100 200 1 3
end data.
execute.

numeric id(f8.0).
compute id=$casenum.
execute.
variable level all (scale).

/* trabajar con vectores.

VECTOR Set_Variables=var1 TO var10.
VECTOR y(10).

COMPUTE F1=0.
COMPUTE #y=0.

LOOP #J=1 TO 10.
-         DO IF NOT MISSING(Set_Variables(#J)).
-               COMPUTE F1=0.
-                LOOP #K=1 TO 10.
-                        IF (#J<>#K) AND (Set_Variables(#J)=Set_Variables(#K)) F1=1.
-                        IF F1=1 repetido=(Set_Variables(#J)).
-                        compute #y=#y+1.
-                        compute y(#y)=Set_Variables(#K).
-               END LOOP.
-               DO IF F1=1.
-                    PRINT / 'Número Cuest.' id ' Códigos duplicados ---> ' repetido '  SET de '+
                                   'códigos ---> '  var1 TO var10.
-               END IF.
-         END IF.
END LOOP.
exe.

--
Javier Figueroa
Procesamiento y Análisis de bases de datos
Cel: 5927-4748 / 4970-1940
Casa: 2289-0184

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Capture information of existing variables in new variables

David Marso
Administrator
I have NO idea of what you are up to here.  Your description does not reflect
the example data. What is the purpose of this exercise?



-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Capture information of existing variables in new variables

Rich Ulrich
In reply to this post by Javier Figueroa

I see at least part of what you want. I think your logic will be easier to write and debug if you separate out the parts.


You want to "squeeze out" the zeroes (= Missing). That is a fairly simple loop.  Maybe you want to stop after you find the first 5 non-Missing values, out of the 384. Do that first, separately.


You want to report whether there are any duplicated values, since those are defined as "error".

 - Maybe that is in the first 5, or maybe that is in the whole record. 

 - Your error-trapping output lists the whole record (instead of, say, its ID).  That's not very useful.


While you are doing the simple loop that squeezes out zeroes, you could have a separate vector that preserves the original index (#Y) of each variable, so your result is the squeezed vector plus a locations-vector.  Then you could have a different report, using PRINT, which shows the values and locations which happen to match, in the course of looping through the tests for duplicates.


Does that capture the problem?

--

Rich Ulrich


From: SPSSX(r) Discussion <[hidden email]> on behalf of Javier Figueroa <[hidden email]>
Sent: Wednesday, February 28, 2018 8:38:17 PM
To: [hidden email]
Subject: Capture information of existing variables in new variables
 
Good afternoon, group of experts with the SPSS program

I have a problem that I have not been able to solve and I would like you to help me.

In my possession I have a database which includes 384 variables (var1 to var384) and I need to go through all the variables and leave the first 5 consecutive answers, besides showing a list of possible repeated codes (errors), I have this syntax and It works a bit, I could not get the codes to leave them consecutively, where there is 0 to omit and put the next one. ex. exists in the original base var1 = 0, var2 = 1, var3 = 3, var4 = 384, var5 = 200, var6 = 0, var7 = 0, var8 = 0, var9 = 5 and I want the base to be with new variables var_new1 = 1, var_new2 = 3, var_new3 = 384, var_new4 = 200, var_new5 = 5. Any comments and / or help I will be very grateful

This is the code or syntax that I generated.


data list list
/var1 to var384.
begin data.
1 1 5 150 0 0 0 0 15 20
3 1 3 180 50 35 0 80 0 35
5 3 4 350 0 384 35 30 0 80
6 4 5 80 80 0 35 384 200 350
7 5 3 200 0 50 30 0 200 1
8 3 280 25 0 0 50 10 2 3
5 5 35 5 0 10 15 0 5 10
6 7 40 384 66 0 0 0 100 384
7 2 50 35 80 35 340 200 0 1
8 2 80 50 0 0 384 100 1 25
9 5 5 40 0 0 0 0 311 250
10 2 20 15 384 0 100 200 1 3
end data.
execute.

numeric id(f8.0).
compute id=$casenum.
execute.
variable level all (scale).

/* trabajar con vectores.

VECTOR Set_Variables=var1 TO var10.
VECTOR y(10).

COMPUTE F1=0.
COMPUTE #y=0.

LOOP #J=1 TO 10.
-         DO IF NOT MISSING(Set_Variables(#J)).
-               COMPUTE F1=0.
-                LOOP #K=1 TO 10.
-                        IF (#J<>#K) AND (Set_Variables(#J)=Set_Variables(#K)) F1=1.
-                        IF F1=1 repetido=(Set_Variables(#J)).
-                        compute #y=#y+1.
-                        compute y(#y)=Set_Variables(#K).
-               END LOOP.
-               DO IF F1=1.
-                    PRINT / 'Número Cuest.' id ' Códigos duplicados ---> ' repetido '  SET de '+
                                   'códigos ---> '  var1 TO var10.
-               END IF.
-         END IF.
END LOOP.
exe.

--
Javier Figueroa
Procesamiento y Análisis de bases de datos
Cel: 5927-4748 / 4970-1940
Casa: 2289-0184

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Capture information of existing variables in new variables

Javier Figueroa
I apologize to you David and Rich, but I think it's my English and I thank you for your prompt response.

I am trying to report repeated codes in a set of variables that include from 1 to 384 and report them in a list with the PRINT command, then, I try to capture the first 5 answers in new variables omitting the zeros and the missing cases.

in the example, I enter data only in 10 variables but in the original database there is information in the 384.

As Rich explains, it's what I need,

Thank you very much for your help, I am very grateful for your contributions and this wonderful community.

Sincerely,

2018-02-28 22:07 GMT-06:00 Rich Ulrich <[hidden email]>:

I see at least part of what you want. I think your logic will be easier to write and debug if you separate out the parts.


You want to "squeeze out" the zeroes (= Missing). That is a fairly simple loop.  Maybe you want to stop after you find the first 5 non-Missing values, out of the 384. Do that first, separately.


You want to report whether there are any duplicated values, since those are defined as "error".

 - Maybe that is in the first 5, or maybe that is in the whole record. 

 - Your error-trapping output lists the whole record (instead of, say, its ID).  That's not very useful.


While you are doing the simple loop that squeezes out zeroes, you could have a separate vector that preserves the original index (#Y) of each variable, so your result is the squeezed vector plus a locations-vector.  Then you could have a different report, using PRINT, which shows the values and locations which happen to match, in the course of looping through the tests for duplicates.


Does that capture the problem?

--

Rich Ulrich


From: SPSSX(r) Discussion <[hidden email]> on behalf of Javier Figueroa <[hidden email]>
Sent: Wednesday, February 28, 2018 8:38:17 PM
To: [hidden email]
Subject: Capture information of existing variables in new variables
 
Good afternoon, group of experts with the SPSS program

I have a problem that I have not been able to solve and I would like you to help me.

In my possession I have a database which includes 384 variables (var1 to var384) and I need to go through all the variables and leave the first 5 consecutive answers, besides showing a list of possible repeated codes (errors), I have this syntax and It works a bit, I could not get the codes to leave them consecutively, where there is 0 to omit and put the next one. ex. exists in the original base var1 = 0, var2 = 1, var3 = 3, var4 = 384, var5 = 200, var6 = 0, var7 = 0, var8 = 0, var9 = 5 and I want the base to be with new variables var_new1 = 1, var_new2 = 3, var_new3 = 384, var_new4 = 200, var_new5 = 5. Any comments and / or help I will be very grateful

This is the code or syntax that I generated.


data list list
/var1 to var384.
begin data.
1 1 5 150 0 0 0 0 15 20
3 1 3 180 50 35 0 80 0 35
5 3 4 350 0 384 35 30 0 80
6 4 5 80 80 0 35 384 200 350
7 5 3 200 0 50 30 0 200 1
8 3 280 25 0 0 50 10 2 3
5 5 35 5 0 10 15 0 5 10
6 7 40 384 66 0 0 0 100 384
7 2 50 35 80 35 340 200 0 1
8 2 80 50 0 0 384 100 1 25
9 5 5 40 0 0 0 0 311 250
10 2 20 15 384 0 100 200 1 3
end data.
execute.

numeric id(f8.0).
compute id=$casenum.
execute.
variable level all (scale).

/* trabajar con vectores.

VECTOR Set_Variables=var1 TO var10.
VECTOR y(10).

COMPUTE F1=0.
COMPUTE #y=0.

LOOP #J=1 TO 10.
-         DO IF NOT MISSING(Set_Variables(#J)).
-               COMPUTE F1=0.
-                LOOP #K=1 TO 10.
-                        IF (#J<>#K) AND (Set_Variables(#J)=Set_Variables(#K)) F1=1.
-                        IF F1=1 repetido=(Set_Variables(#J)).
-                        compute #y=#y+1.
-                        compute y(#y)=Set_Variables(#K).
-               END LOOP.
-               DO IF F1=1.
-                    PRINT / 'Número Cuest.' id ' Códigos duplicados ---> ' repetido '  SET de '+
                                   'códigos ---> '  var1 TO var10.
-               END IF.
-         END IF.
END LOOP.
exe.

--
Javier Figueroa
Procesamiento y Análisis de bases de datos
Cel: 5927-4748 / 4970-1940
Casa: 2289-0184

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD



--
Javier Figueroa
Procesamiento y Análisis de bases de datos
Cel: 5927-4748 / 4970-1940
Casa: 2289-0184

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Capture information of existing variables in new variables

David Marso
Administrator
In reply to this post by Javier Figueroa
Maybe I am dense but I fail to see the relationship between:

var1 = 0, var2 = 1, var3 = 3, var4 = 384, var5 = 200, var6 = 0, var7 = 0,
var8 = 0, var9 = 5 and I want the base to be with new variables var_new1 =
1, var_new2 = 3, var_new3 = 384, var_new4 = 200, var_new5 = 5.

and anything in the posted data.  Would you care to elaborate?



-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Capture information of existing variables in new variables

Rich Ulrich

... squeezing out the zeroes ...

0, 1, 3, 385, 200, 0, 0, 0, 5 in var(1..9) becomes

1, 3, 385, 200, 5  in var_new(1..5)


__
Rich Ulrich

From: SPSSX(r) Discussion <[hidden email]> on behalf of David Marso <[hidden email]>
Sent: Thursday, March 1, 2018 10:00 PM
To: [hidden email]
Subject: Re: Capture information of existing variables in new variables
 
Maybe I am dense but I fail to see the relationship between:

var1 = 0, var2 = 1, var3 = 3, var4 = 384, var5 = 200, var6 = 0, var7 = 0,
var8 = 0, var9 = 5 and I want the base to be with new variables var_new1 =
1, var_new2 = 3, var_new3 = 384, var_new4 = 200, var_new5 = 5.

and anything in the posted data.  Would you care to elaborate?
...

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Capture information of existing variables in new variables

David Marso
Administrator
Ok... I was expecting there to be some relationship to the sample data!!!

VARSTOCASES with an index.-> value index
SELECT non zeroes
AGGREGATE breaking on ID and value get first index
CASESTOVARS 😎



Rich Ulrich wrote

> ... squeezing out the zeroes ...
>
> 0, 1, 3, 385, 200, 0, 0, 0, 5 in var(1..9) becomes
>
> 1, 3, 385, 200, 5  in var_new(1..5)
>
> __
> Rich Ulrich
> ________________________________
> From: SPSSX(r) Discussion &lt;

> SPSSX-L@.UGA

> &gt; on behalf of David Marso &lt;

> david.marso@

> &gt;
> Sent: Thursday, March 1, 2018 10:00 PM
> To:

> SPSSX-L@.UGA

> Subject: Re: Capture information of existing variables in new variables
>
> Maybe I am dense but I fail to see the relationship between:
>
> var1 = 0, var2 = 1, var3 = 3, var4 = 384, var5 = 200, var6 = 0, var7 = 0,
> var8 = 0, var9 = 5 and I want the base to be with new variables var_new1 =
> 1, var_new2 = 3, var_new3 = 384, var_new4 = 200, var_new5 = 5.
>
> and anything in the posted data.  Would you care to elaborate?
> ...
>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD

C



-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Capture information of existing variables in new variables

David Marso
Administrator
Like this:
data list list /var01 to var10.
begin data.
1 1 5 150 0 0 0 0 15 20
3 1 3 180 50 35 0 80 0 35
5 3 4 350 0 384 35 30 0 80
6 4 5 80 80 0 35 384 200 350
7 5 3 200 0 50 30 0 200 1
8 3 280 25 0 0 50 10 2 3
5 5 35 5 0 10 15 0 5 10
6 7 40 384 66 0 0 0 100 384
7 2 50 35 80 35 340 200 0 1
8 2 80 50 0 0 384 100 1 25
9 5 5 40 0 0 0 0 311 250
10 2 20 15 384 0 100 200 1 3
end data.

COMPUTE ID=$casenum.
VARSTOCASES MAKE Value FROM var01 to var10/INDEX=Location.
SELECT IF (Value NE 0) .
AGGREGATE OUTFILE * / BREAK ID Value /Location=FIRST(Location)/Count=N.
SORT CASES BY ID Location.
DATASET COPY dups.
DELETE VARIABLES Location Count.
CASESTOVARS ID=ID.
DATASET ACTIVATE dups.
SELECT IF ( Count GT 1).
EXECUTE.
DELETE VARIABLES Location Count.
CASESTOVARS ID=ID.
TITLE "Duplicated values".
LIST.


David Marso wrote
> Ok...
*
>  I was expecting there to be some relationship to the sample data
*

> !!!
>
> VARSTOCASES with an index.-> value index
> SELECT non zeroes
> AGGREGATE breaking on ID and value get first index
> CASESTOVARS 😎
>
>
>
> Rich Ulrich wrote
>> ... squeezing out the zeroes ...
>>
>> 0, 1, 3, 385, 200, 0, 0, 0, 5 in var(1..9) becomes
>>
>> 1, 3, 385, 200, 5  in var_new(1..5)
>>
>> __
>> Rich Ulrich
>> ________________________________
>> From: SPSSX(r) Discussion &lt;
>
>> SPSSX-L@.UGA
>
>> &gt; on behalf of David Marso &lt;
>
>> david.marso@
>
>> &gt;
>> Sent: Thursday, March 1, 2018 10:00 PM
>> To:
>
>> SPSSX-L@.UGA
>
>> Subject: Re: Capture information of existing variables in new variables
>>
>> Maybe I am dense but I fail to see the relationship between:
>>
>> var1 = 0, var2 = 1, var3 = 3, var4 = 384, var5 = 200, var6 = 0, var7 = 0,
>> var8 = 0, var9 = 5 and I want the base to be with new variables var_new1
>> =
>> 1, var_new2 = 3, var_new3 = 384, var_new4 = 200, var_new5 = 5.
>>
>> and anything in the posted data.  Would you care to elaborate?
>> ...
>>
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (not to SPSSX-L), with no body text except the
>> command. To leave the list, send the command
>> SIGNOFF SPSSX-L
>> For a list of commands to manage subscriptions, send the command
>> INFO REFCARD
>
> C
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
> ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
> abyssum?"
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: Capture information of existing variables in new variables

Art Kendall
In reply to this post by Javier Figueroa
I am not sure I follow what you are trying to do.

Are these  correct?
-- the same values may occur in any of the 384 variables?
-- A value may occur more than once in an individual case? This is OK or NOT
OK?

If so, and if you are trying to get a combined frequency count across the
set, look at MULT RESPONSE.

You can look at a multiple response set by itself, by crosstabbing it by it
self, or by crosstabbing it by other variables.  

I am not sure if TABLES is an extra cost option. If it is not or if you have
access to it you can define multiple response sets in TABLES.

You will usually get better advice when you describe you situation in more
concrete terms.
What is a case?
What do the 384 variables mean as a set?
What is the meaning of a value of zero?
etc.





-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Capture information of existing variables in new variables

Javier Figueroa
In reply to this post by David Marso
Thanks for the help, the contribution is very useful, it seems that I am complicating my life. SPSS is so powerful that there are several ways to execute a process.

I would like to ask, when listing the duplicates the SELECT IF command does not affect the original base? If it affects it, it would add a SAVE command before listing the duplicates.

AND I PRAY THEY APOLOGIZE FOR MY ENGLISH, I know that at some point I can confuse them, I thank them for the contribution, Rich and David.


note: I will study the VARSTOCASES and AGGREGATE commands more.
 
Sincerely,

2018-03-02 6:11 GMT-06:00 David Marso <[hidden email]>:
Like this:
data list list /var01 to var10.
begin data.
1 1 5 150 0 0 0 0 15 20
3 1 3 180 50 35 0 80 0 35
5 3 4 350 0 384 35 30 0 80
6 4 5 80 80 0 35 384 200 350
7 5 3 200 0 50 30 0 200 1
8 3 280 25 0 0 50 10 2 3
5 5 35 5 0 10 15 0 5 10
6 7 40 384 66 0 0 0 100 384
7 2 50 35 80 35 340 200 0 1
8 2 80 50 0 0 384 100 1 25
9 5 5 40 0 0 0 0 311 250
10 2 20 15 384 0 100 200 1 3
end data.

COMPUTE ID=$casenum.
VARSTOCASES MAKE Value FROM var01 to var10/INDEX=Location.
SELECT IF (Value NE 0) .
AGGREGATE OUTFILE * / BREAK ID Value /Location=FIRST(Location)/Count=N.
SORT CASES BY ID Location.
DATASET COPY dups.
DELETE VARIABLES Location Count.
CASESTOVARS ID=ID.
DATASET ACTIVATE dups.
SELECT IF ( Count GT 1).
EXECUTE.
DELETE VARIABLES Location Count.
CASESTOVARS ID=ID.
TITLE "Duplicated values".
LIST.


David Marso wrote
> Ok...
*
>  I was expecting there to be some relationship to the sample data
*
> !!!
>
> VARSTOCASES with an index.-> value index
> SELECT non zeroes
> AGGREGATE breaking on ID and value get first index
> CASESTOVARS 😎
>
>
>
> Rich Ulrich wrote
>> ... squeezing out the zeroes ...
>>
>> 0, 1, 3, 385, 200, 0, 0, 0, 5 in var(1..9) becomes
>>
>> 1, 3, 385, 200, 5  in var_new(1..5)
>>
>> __
>> Rich Ulrich
>> ________________________________
>> From: SPSSX(r) Discussion &lt;
>
>> SPSSX-L@.UGA
>
>> &gt; on behalf of David Marso &lt;
>
>> david.marso@
>
>> &gt;
>> Sent: Thursday, March 1, 2018 10:00 PM
>> To:
>
>> SPSSX-L@.UGA
>
>> Subject: Re: Capture information of existing variables in new variables
>>
>> Maybe I am dense but I fail to see the relationship between:
>>
>> var1 = 0, var2 = 1, var3 = 3, var4 = 384, var5 = 200, var6 = 0, var7 = 0,
>> var8 = 0, var9 = 5 and I want the base to be with new variables var_new1
>> =
>> 1, var_new2 = 3, var_new3 = 384, var_new4 = 200, var_new5 = 5.
>>
>> and anything in the posted data.  Would you care to elaborate?
>> ...
>>
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (not to SPSSX-L), with no body text except the
>> command. To leave the list, send the command
>> SIGNOFF SPSSX-L
>> For a list of commands to manage subscriptions, send the command
>> INFO REFCARD
>
> C
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
> ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
> abyssum?"
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD



--
Javier Figueroa
Procesamiento y Análisis de bases de datos
Cel: 5927-4748 / 4970-1940
Casa: 2289-0184

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD