Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Potential Problem with Tag

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str7 MCSID byte(GC_S_QUAL_GCSE GC_S_QUAL_BTEC GC_S_QUAL_GCSN_R20 GC_L_GCGD GC_L_GCDB GC_L_BTGD) float(GCSE DoubleAward BTEC GCSEDA TOTALSCOREage17) byte tag
    "M10016V" -1 -1 -1 -1 -1 -1 0 1 0 59 59 1
    "M10044Z" -1 -1 -1 -1 -1 -1 0 1 0 48 48 1
    "M10062B" -1 -1 -1 11  2 -1 8 1 0 72 72 1
    "M10068H" -1 -1 -1 14  1 -1 5 2 0 59 59 1
    "M10083G" -1 -1 -1 13  2 -1 6 1 0 54 54 1
    "M10113V"  .  .  .  .  .  . . 1 .  0  . 1
    "M10114W" -1 -1 -1 -1 -1 -1 0 1 0 21 21 1
    "M10134A" -1 -1 -1 16  2 -1 3 1 0 48 48 1
    "M10146E" -1 -1 -1 11  2 -1 8 1 0 72 72 1
    "M10153D" -1 -1 -1 -1 -1 -1 0 1 0 44 44 1
    "M10195P" -1 -1 -1 -1 -1 -1 0 1 0  0  0 1
    "M10313B" -1 -1 -1 -1 -1 -1 0 1 0 53 53 1
    "M10349P" -1 -1 -1 14  2 -1 5 1 0 33 33 1
    "M10379V" -1 -1 -1 -1 -1 -1 0 1 0  0  0 1
    "M10391R"  .  .  .  .  .  . . 1 .  0  . 1
    "M10455Q" -1 -1 -1 15  2 -1 4 1 0 18 18 1
    "M10492V" -1 -1 -1 -1 -1 -1 0 1 0 19 19 1
    "M10537R" -1 -1 -1 14  2 -1 5 1 0 55 55 1
    "M10541M" -1 -1 -1 -1 -1 -1 0 1 0  0  0 1
    "M10567X" -1 -1 -1 -1 -1 -1 0 1 0 29 29 1
    "M10596C" -1 -1 -1 -1 -1 -1 0 1 0 36 36 1
    "M10603J" -1 -1 -1 13  2 -1 6 1 0 40 40 1
    "M10614M" -1 -1 -1 -1 -1 -1 0 1 0 21 21 1
    "M10617Q" -1 -1 -1 12  2 -1 7 1 0 48 48 1
    "M10620K" -1 -1 -1 11  2 -1 8 1 0 61 61 1
    "M10639W" -1 -1 -1 14  2 -1 5 1 0 40 40 1
    "M10672X" -1 -1 -1 -1 -1 -1 0 1 0  0  0 1
    "M10675A" -1 -1 -1 -1 -1 -1 0 1 0 45 45 1
    "M10683A"  .  .  .  .  .  . . 1 .  0  . 1
    "M10688F"  .  .  .  .  .  . . 1 .  0  . 1
    "M10728W" -1 -1 -1 14  2 -1 5 1 0 33 33 1
    "M10762Y" -1 -1 -1 -1 -1 -1 0 1 0 46 46 1
    "M10781B" -1 -1 -1 -1 -1 -1 0 1 0 40 40 1
    "M10801N" -1 -1 -1 -1 -1 -1 0 1 0 71 71 1
    "M10804R"  .  .  .  .  .  . . 1 .  0  . 1
    "M10809W"  1  2  8 12  2 -1 7 1 0 43 43 1
    "M10816V" -1 -1 -1 -1 -1 -1 0 1 0 73 73 1
    "M10819Y" -1 -1 -1 -1 -1 -1 0 1 0 67 67 1
    "M10843Y" -1 -1 -1 -1 -1 -1 0 1 0 59 59 1
    "M10900Q" -1 -1 -1 -1 -1 -1 0 1 0 18 18 1
    "M10914W" -1 -1 -1 -1 -1 -1 0 1 0  0  0 1
    "M10998S" -1 -1 -1 -1 -1 -1 0 1 0 50 50 1
    "M11006X" -1 -1 -1 14  2 -1 5 1 0 54 54 1
    "M11019C" -1 -1 -1 -1 -1 -1 0 1 0 43 43 1
    "M11077N" -1 -1 -1 13  2 -1 6 1 0 57 57 1
    "M11091L" -1 -1 -1 -1 -1 -1 0 1 0 78 78 1
    "M11167P" -1 -1 -1 -1 -1 -1 0 1 0 45 45 1
    "M11171K"  .  .  .  .  .  . . 1 .  0  . 1
    "M11197V" -1 -1 -1 15  2 -1 4 1 0 45 45 1
    "M11220B" -1 -1 -1 -1 -1 -1 0 1 0 66 66 1
    "M11231E" -1 -1 -1 13  2 -1 6 1 0 69 69 1
    "M11247N" -1 -1 -1 -1 -1 -1 0 1 0  0  0 1
    "M11295W" -1 -1 -1 -1 -1 -1 0 1 0 59 59 1
    "M11335M" -1 -1 -1 14  2 -1 5 1 0 54 54 1
    "M11345P" -1 -1 -1 -1 -1 -1 0 1 0 50 50 1
    "M11356S"  .  .  .  .  .  . . 1 .  0  . 1
    "M11370Q" -1 -1 -1 -1 -1 -1 0 1 0 45 45 1
    "M11386Y" -1 -1 -1 -1 -1 -1 0 1 0 63 63 1
    "M11395Z" -1 -1 -1 -1 -1 -1 0 1 0 59 59 1
    "M11403G" -1 -1 -1 -1 -1 -1 0 1 0 31 31 1
    "M11422K" -1 -1 -1 -1 -1 -1 0 1 0 66 66 1
    "M11428R" -1 -1 -1 -1 -1 -1 0 1 0 55 55 1
    "M11450P"  .  .  .  .  .  . . 1 .  0  . 1
    "M11466X" -1 -1 -1 12  2 -1 7 1 0 69 69 1
    "M11477A" -1 -1 -1 -1 -1 -1 0 1 0 56 56 1
    "M11505M" -1 -1 -1 13  2 -1 6 1 0 67 67 1
    "M11596G" -1 -1 -1 -1 -1 -1 0 1 0 19 19 1
    "M11742Y"  .  .  .  .  .  . . 1 .  0  . 1
    "M11753B" -1 -1 -1 -1 -1 -1 0 1 0 57 57 1
    "M11763D" -1 -1 -1 12  2 -1 7 1 0 83 83 1
    "M11774G" -1 -1 -1 -1 -1 -1 0 1 0 38 38 1
    "M11789P" -1 -1 -1 -1 -1 -1 0 1 0  0  0 1
    "M11805W" -1 -1 -1 -1 -1 -1 0 1 0 40 40 1
    "M11816Z" -1 -1 -1 -1 -1 -1 0 1 0 50 50 1
    "M11845E" -1 -1 -1 -1 -1 -1 0 1 0 77 77 1
    "M11876M" -1 -1 -1 -1 -1 -1 0 1 0 52 52 1
    "M11889S" -1 -1 -1 -1 -1 -1 0 1 0 64 64 1
    "M11949M" -1 -1 -1 14  2 -1 5 1 0 31 31 1
    "M12039L" -1 -1 -1 13  2 -1 6 1 0 59 59 1
    "M12079U" -1 -1 -1 -1 -1 -1 0 1 0 22 22 1
    "M12099Y" -1 -1 -1 -1 -1 -1 0 1 0 52 52 1
    "M12165R" -1 -1 -1 -1 -1 -1 0 1 0 77 77 1
    "M12166S" -1 -1 -1 -1 -1 -1 0 1 0 68 68 1
    "M12189Z" -1 -1 -1 -1 -1 -1 0 1 0 31 31 1
    "M12199B" -1 -1 -1 -1 -1 -1 0 1 0 46 46 1
    "M12223J" -1 -1 -1 -1 -1 -1 0 1 0 54 54 1
    "M12234M" -1 -1 -1 -1 -1 -1 0 1 0 49 49 1
    "M12240K" -1 -1 -1 -1 -1 -1 0 1 0 54 54 1
    "M12271S" -1 -1 -1 -1 -1 -1 0 1 0 32 32 1
    "M12272T" -1 -1 -1 11  2 -1 8 1 0 60 60 1
    "M12293Y" -1 -1 -1 -1 -1 -1 0 1 0 32 32 1
    "M12364W" -1 -1 -1 -1 -1 -1 0 1 0 47 47 1
    "M12386C" -1 -1 -1 -1 -1 -1 0 1 0 56 56 1
    "M12402K" -1 -1 -1 13  2 -1 6 1 0 99 99 1
    "M12461W" -1 -1 -1 -1 -1 -1 0 1 0  6  6 1
    "M12464Z" -1 -1 -1 -1 -1 -1 0 1 0 40 40 1
    "M12480Z"  .  .  .  .  .  . . 1 .  0  . 1
    "M12547B" -1 -1 -1 12  2 -1 7 1 0 58 58 1
    "M12567F" -1 -1 -1 12  2 -1 7 1 0 62 62 1
    "M12579K" -1 -1 -1 -1 -1 -1 0 1 0  5  5 1
    end
    label values GC_S_QUAL_GCSE GC_S_QUAL_GCSE
    label def GC_S_QUAL_GCSE -1 "Not applicable", modify
    label def GC_S_QUAL_GCSE 1 "GCSE", modify
    label values GC_S_QUAL_BTEC GC_S_QUAL_BTEC
    label def GC_S_QUAL_BTEC -1 "Not applicable", modify
    label def GC_S_QUAL_BTEC 2 "No", modify
    label values GC_S_QUAL_GCSN_R20 GC_S_QUAL_GCSN_R20
    label def GC_S_QUAL_GCSN_R20 -1 "Not applicable", modify
    label def GC_S_QUAL_GCSN_R20 8 "8", modify
    label values GC_L_GCGD GC_L_GCGD
    label def GC_L_GCGD -1 "Not applicable", modify
    label def GC_L_GCGD 11 "A*", modify
    label def GC_L_GCGD 12 "A", modify
    label def GC_L_GCGD 13 "B", modify
    label def GC_L_GCGD 14 "C", modify
    label def GC_L_GCGD 15 "D", modify
    label def GC_L_GCGD 16 "E", modify
    label values GC_L_GCDB GC_L_GCDB
    label def GC_L_GCDB -1 "Not applicable", modify
    label def GC_L_GCDB 1 "Double Award", modify
    label def GC_L_GCDB 2 "Not", modify
    label values GC_L_BTGD GC_L_BTGD
    label def GC_L_BTGD -1 "Not applicable", modify
    ------------------ copy up to and including the previous line ------------------

    gen GCSE = GC_L_GCGD

    recode GCSE (-9=0) (-8=0) (-1=0) (1=0) (2=0) (3=0) (4=0) (5=0) (6=0) (7=0) (8=0) (9=0) (10=0) (11=8) (12=7) (13=6) (14=5) (15=4) (16=3) (17=2) (18=1)


    * recode double award so that if the subject is a double award you multiply it by grade number by 2

    gen DoubleAward = GC_L_GCDB

    recode DoubleAward (-1=1) (1=2) (2=1) (.=1)

    gen BTEC = GC_L_BTGD

    recode BTEC (-8=0) (-1=0) (1=5) (2=6) (3=7)

    * GC_L_GCGD records the score obtained relating to each subject examined. GC_L_GCDB states whether the exam is 'double award' in which case the score obtained needs to be doubled.

    by MCSID, sort: egen GCSEDA = total(DoubleAward*GCSE)

    * need to add this to BTEC scores to get a final score for exams sat at age 16.

    gen TOTALSCOREage17 = BTEC + GCSEDA

    label variable TOTALSCOREage17 "Total academic score at GCSE/BTEC"

    * created a tag to try and get one row per MCSID instead of several rows with the same values

    egen tag = tag(MCSID)

    keep if tag==1


    I have been trying to get a single overall academic score for each MCSID which includes a total overall GCSE score and a BTEC score. The above appears to work until the tag command. For some reason it is not picking up the BTEC scores when there are no GCSE results. For any child who just has BTEC results the tag puts them at 0, ignoring their score at BTEC. If the child does have a GCSE and a BTEC score it is correctly added and retained.

    Would welcome any advice, many thanks, JRea

  • #2
    Why should the tag() function do or know anything about any other variable than that mentioned?

    Comment


    • #3
      Good point, I looked at variables again and used GC_ROWID==1 and CNUM00==1 which worked. Many thanks, JRea

      Comment

      Working...
      X