|
Hi,
I have a data file of grant rewards. There are awards that are coded (p) parent (the main reward) and sub-recipients (coded as "s") receive a portion of the parent or main reward. A parent can just be a parent award with no sub-recipients. All sub-recipients should have a parent award and will have the same grant# as the parent award but will be coded âsâ. But in this list some sub-recipients do not have a parent and I want to be able to identify these and then recode them as "o" or orphans. For example: grant1 and grant2 are parents only and are designated "p". Grant 3 is the parent "p" of grants 4-6 which are sub-recipients and are appropriately "s" to that parent. Now, grant 7-9 and 10-11 are sub- recipients of missing parents and I want to recode them as "o" for orphans so that there is a new variable (New Grant Role). Can you please help me with syntax to do this? I am only good at simple syntax and can't seem to do this. Thanks everyone! line# grant# grant_role New grant role 1 0838917 P P 2 0840733 P P 3 054-RARA-B58Y P P 4 054-RARA-B58Y S S 5 054-RARA-B58Y S S 6 054-RARA-B58Y S S 7 0901MNCCD7 S O 8 0901MNCCD7 S O 9 0901MNCCD7 S O 10 0901MNCOS2 S O 11 0901MNCOS2 S O Zana Dael ===================== 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 |
|
Hello, Zana,
is it this what you're looking for?
* ========================================.
DATA LIST / line 1-2 grant 4-16 (A) grant_role 18 (A) new_grant_role 20 (A). BEGIN DATA
01 0838917 P P 02 0840733 P P 03 054-RARA-B58Y P P 04 054-RARA-B58Y S S 05 054-RARA-B58Y S S 06 054-RARA-B58Y S S 07 0901MNCCD7 S O 08 0901MNCCD7 S O 09 0901MNCCD7 S O 10 0901MNCOS2 S O 11 0901MNCOS2 S O END DATA. EXECUTE. STRING new_grant_role (A1).
DO IF (LAG(grant) NE grant AND grant_role EQ "P") /* predecessor grant unequal, grant role Parent*/. - COMPUTE new_grant_role = "P". ELSE IF (LAG(grant) NE grant AND grant_role NE "P") /* predecessor grant unequal, grant role no Parent */. - COMPUTE new_grant_role = "O". ELSE IF (LAG(grant) EQ grant AND LAG(grant_role) = "P") /* predecessor grant equal with grant role Parent*/. - COMPUTE new_grant_role = "S". ELSE IF (LAG(grant) EQ grant AND LAG(grant_role) NE "P") /* predecessor grant equal with grant role no Parent*/. - COMPUTE new_grant_role = LAG(new_grant_role2). END IF. EXE. * ========================================. Good luck, Mario
Von: Zana Dael <[hidden email]> An: [hidden email] Gesendet: Freitag, den 8. Januar 2010, 19:46:59 Uhr Betreff: identify missing values and recode Hi, I have a data file of grant rewards. There are awards that are coded (p) parent (the main reward) and sub-recipients (coded as "s") receive a portion of the parent or main reward. A parent can just be a parent award with no sub-recipients. All sub-recipients should have a parent award and will have the same grant# as the parent award but will be coded “s”. But in this list some sub-recipients do not have a parent and I want to be able to identify these and then recode them as "o" or orphans. For example: grant1 and grant2 are parents only and are designated "p". Grant 3 is the parent "p" of grants 4-6 which are sub-recipients and are appropriately "s" to that parent. Now, grant 7-9 and 10-11 are sub- recipients of missing parents and I want to recode them as "o" for orphans so that there is a new variable (New Grant Role). Can you please help me with syntax to do this? I am only good at simple syntax and can't seem to do this. Thanks everyone! line# grant# grant_role New grant role 1 0838917 P P 2 0840733 P P 3 054-RARA-B58Y P P 4 054-RARA-B58Y S S 5 054-RARA-B58Y S S 6 054-RARA-B58Y S S 7 0901MNCCD7 S O 8 0901MNCCD7 S O 9 0901MNCCD7 S O 10 0901MNCOS2 S O 11 0901MNCOS2 S O Zana Dael ===================== 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 __________________________________________________ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com
Mario Giesel
Munich, Germany |
|
In reply to this post by Zana Dael
At 01:46 PM 1/8/2010, Zana Dael wrote:
I have a data file of grant rewards. Some awards that are coded (p) parent (the main reward) and sub-recipients (coded as "s") receive a portion of the main reward. All sub-recipients should have a parent award and will have the same grant# as the parent award but will be coded ["s" (?coding garbled)]. Some sub-recipients do not have a parent and I want to identify these and then recode them as "o" or orphans. In the following, the first listing is the posted test data, which includes the desired result as variable "New_grant_role". The result includes variable "Parented"; I hope that's not a severe drawback. [Grants] line# grant# grant_role New_grant_role 1 0838917 P P 2 0840733 P P 3 054-RARA-B58Y P P 4 054-RARA-B58Y S S 5 054-RARA-B58Y S S 6 054-RARA-B58Y S S 7 0901MNCCD7 S O 8 0901MNCCD7 S O 9 0901MNCCD7 S O 10 0901MNCOS2 S O 11 0901MNCOS2 S O Number of cases read: 11 Number of cases listed: 11 SORT CASES BY grant#. NEW FILE. ADD FILE /FILE=Grants /RENAME grant_role=parent_grant_role /KEEP= grant# parent_grant_role. SELECT IF parent_grant_role = 'P'. DATASET NAME Parents. DATASET ACTIVATE Grants WINDOW=FRONT. MATCH FILES /FILE =* /TABLE=Parents /IN=Parented /BY grant# /DROP =parent_grant_role. STRING Calc_New_Role (A1). COMPUTE Calc_New_Role=grant_role. IF Calc_New_Role EQ 'S' AND NOT Parented Calc_New_Role = 'O'. SORT CASES BY line#. LIST. List |-----------------------------|---------------------------| |Output Created |09-JAN-2010 13:42:11 | |-----------------------------|---------------------------| [Grants] line# grant# grant_role New_grant_role Parented Calc_New_Role 1 0838917 P P 1 P 2 0840733 P P 1 P 3 054-RARA-B58Y P P 1 P 4 054-RARA-B58Y S S 1 S 5 054-RARA-B58Y S S 1 S 6 054-RARA-B58Y S S 1 S 7 0901MNCCD7 S O 0 O 8 0901MNCCD7 S O 0 O 9 0901MNCCD7 S O 0 O 10 0901MNCOS2 S O 0 O 11 0901MNCOS2 S O 0 O Number of cases read: 11 Number of cases listed: 11 ============================= APPENDIX: Test data, and code ============================= DATA LIST LIST/ line# grant# grant_role New_grant_role (F2, A13, A1, A1). BEGIN DATA 1 0838917 P P 2 0840733 P P 3 054-RARA-B58Y P P 4 054-RARA-B58Y S S 5 054-RARA-B58Y S S 6 054-RARA-B58Y S S 7 0901MNCCD7 S O 8 0901MNCCD7 S O 9 0901MNCCD7 S O 10 0901MNCOS2 S O 11 0901MNCOS2 S O END DATA. DATASET NAME Grants WINDOW=FRONT. LIST. SORT CASES BY grant#. NEW FILE. ADD FILE /FILE=Grants /RENAME grant_role=parent_grant_role /KEEP= grant# parent_grant_role. SELECT IF parent_grant_role = 'P'. DATASET NAME Parents. DATASET ACTIVATE Grants WINDOW=FRONT. MATCH FILES /FILE =* /TABLE=Parents /IN=Parented /BY grant# /DROP =parent_grant_role. STRING Calc_New_Role (A1). COMPUTE Calc_New_Role=grant_role. IF Calc_New_Role EQ 'S' AND NOT Parented Calc_New_Role = 'O'. SORT CASES BY line#. LIST. ===================== 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 |
|
In reply to this post by Mario Giesel
Thanks to those, Mario and Richard who replied to my email. These worked perfectly and saved me an enormous amount of time. I was going to have to recode by hand.
Zana.
From: Mario Giesel <[hidden email]> To: [hidden email] Sent: Sat, January 9, 2010 5:08:54 AM Subject: AW: identify missing values and recode Hello, Zana,
is it this what you're looking for?
* ========================================.
DATA LIST / line 1-2 grant 4-16 (A) grant_role 18 (A) new_grant_role 20 (A). BEGIN DATA
01 0838917 P P 02 0840733 P P 03 054-RARA-B58Y P P 04 054-RARA-B58Y S S 05 054-RARA-B58Y S S 06 054-RARA-B58Y S S 07 0901MNCCD7 S O 08 0901MNCCD7 S O 09 0901MNCCD7 S O 10 0901MNCOS2 S O 11 0901MNCOS2 S O END DATA. EXECUTE. STRING new_grant_role (A1).
DO IF (LAG(grant) NE grant AND grant_role EQ "P") /* predecessor grant unequal, grant role Parent*/. - COMPUTE new_grant_role = "P". ELSE IF (LAG(grant) NE grant AND grant_role NE "P") /* predecessor grant unequal, grant role no Parent */. - COMPUTE new_grant_role = "O". ELSE IF (LAG(grant) EQ grant AND LAG(grant_role) = "P") /* predecessor grant equal with grant role Parent*/. - COMPUTE new_grant_role = "S". ELSE IF (LAG(grant) EQ grant AND LAG(grant_role) NE "P") /* predecessor grant equal with grant role no Parent*/. - COMPUTE new_grant_role = LAG(new_grant_role2). END IF. EXE. * ========================================. Good luck, Mario
Von: Zana Dael <[hidden email]> An: [hidden email] Gesendet: Freitag, den 8. Januar 2010, 19:46:59 Uhr Betreff: identify missing values and recode Hi, I have a data file of grant rewards. There are awards that are coded (p) parent (the main reward) and sub-recipients (coded as "s") receive a portion of the parent or main reward. A parent can just be a parent award with no sub-recipients. All sub-recipients should have a parent award and will have the same grant# as the parent award but will be coded “s”. But in this list some sub-recipients do not have a parent and I want to be able to identify these and then recode them as "o" or orphans. For example: grant1 and grant2 are parents only and are designated "p". Grant 3 is the parent "p" of grants 4-6 which are sub-recipients and are appropriately "s" to that parent. Now, grant 7-9 and 10-11 are sub- recipients of missing parents and I want to recode them as "o" for orphans so that there is a new variable (New Grant Role). Can you please help me with syntax to do this? I am only good at simple syntax and can't seem to do this. Thanks everyone! line# grant# grant_role New grant role 1 0838917 P P 2 0840733 P P 3 054-RARA-B58Y P P 4 054-RARA-B58Y S S 5 054-RARA-B58Y S S 6 054-RARA-B58Y S S 7 0901MNCCD7 S O 8 0901MNCCD7 S O 9 0901MNCCD7 S O 10 0901MNCOS2 S O 11 0901MNCOS2 S O Zana Dael ===================== 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 __________________________________________________ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com |
| Free forum by Nabble | Edit this page |
