notes13 - Concatenating SAS Data Sets Use the SET statement...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Concatenating SAS Data Sets Use the SET statement in a DATA step to concatenate SAS data sets. Notes 13: Combining Data Sets General form of a DATA step concatenation: DATA SAS-data-set ;; DATA SAS-data-set SET SAS-data-set1 SAS-data-set2 .. ....;; SET SAS-data-set1 SAS-data-set2 <other SAS statements> <other SAS statements> RUN; RUN; 1 2 Concatenating SAS Data Sets You can read any number of SAS data sets with a single SET statement. SAS data sets Business Task Two SAS data sets, na1 and na2, contain data for newly hired navigators. Concatenate the data sets into a new data set named newhires. na1 na2 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 jan feb mar data work.qtr1; set work.jan work.feb work.mar; run; work.qtr1 jan feb mar Name LISTER TORRES Gender JobCode M NA2 F NA2 The data sets contain the same variables. 3 4 Concatenating SAS Data Sets: Compilation na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 Concatenating SAS Data Sets: Compilation na1 na2 JobCode NA1 NA1 NA1 Name TORRES LANG SMITH Gender M F F na2 Name LISTER TORRES Name Gender JobCode M NA2 F NA2 Name LISTER TORRES Name Gender JobCode M NA2 F NA2 data newhires; set na1 na2; run; PDV Gender JobCode data newhires; set na1 na2; run; PDV Gender JobCode No additional variables 5 6 1 Concatenating SAS Data Sets: Compilation na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 Concatenating SAS Data Sets: Execution na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 na2 Name LISTER TORRES Name Gender JobCode M NA2 F NA2 na2 Name LISTER TORRES Name Gender JobCode M NA2 F NA2 data newhires; set na1 na2; run; PDV Gender JobCode data newhires; set na1 na2; run; PDV Gender JobCode newhires newhires Name Gender JobCode Name Gender JobCode Initialize PDV to missing 7 8 Concatenating SAS Data Sets: Execution na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 Concatenating SAS Data Sets: Execution na1 na2 JobCode NA1 NA1 NA1 Name TORRES LANG SMITH Gender M F F na2 Name LISTER TORRES Name Gender JobCode M NA2 F NA2 Name LISTER TORRES Name TORRES Gender JobCode M NA2 F NA2 data newhires; set na1 na2; run; PDV Gender JobCode data newhires; set na1 na2; run; PDV Gender JobCode M NA1 newhires newhires Name Gender JobCode Name Gender JobCode 9 10 Concatenating SAS Data Sets: Execution na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 Concatenating SAS Data Sets: Execution na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 na2 Name LISTER TORRES Name TORRES Gender JobCode M NA2 F NA2 na2 Name LISTER TORRES Name LANG Gender JobCode M NA2 F NA2 data newhires; set na1 na2; run; PDV Gender JobCode M NA1 Automatic output Automatic return newhires Name Gender JobCode TORRES M NA1 data newhires; set na1 na2; run; Automatic return newhires Name TORRES LANG PDV Gender JobCode F NA1 Automatic output Gender JobCode M NA1 F NA1 11 12 2 Concatenating SAS Data Sets: Execution na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 Concatenating SAS Data Sets: Execution na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 na2 Name LISTER TORRES Name SMITH Gender JobCode M NA2 F NA2 na2 Name LISTER TORRES Name SMITH Gender JobCode M NA2 F NA2 data newhires; set na1 na2; run; Automatic return newhires Name TORRES LANG SMITH PDV Gender JobCode F NA1 Automatic output Gender M F F JobCode NA1 NA1 NA1 data newhires; set na1 na2; run; PDV Gender JobCode F NA1 newhires Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 End of File 13 14 Concatenating SAS Data Sets: Execution na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 Concatenating SAS Data Sets: Execution na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 na2 Name LISTER TORRES Name SMITH Gender JobCode M NA2 F NA2 na2 Name LISTER TORRES Name LISTER Gender JobCode M NA2 F NA2 data newhires; set na1 na2; run; PDV Gender JobCode F NA1 newhires Name TORRES LANG SMITH Gender M F F Initialize PDV to missing JobCode NA1 NA1 NA1 data newhires; set na1 na2; run; Automatic return newhires Name TORRES LANG SMITH LISTER PDV Gender JobCode M NA2 Automatic output Gender M F F M JobCode NA1 NA1 NA1 NA2 16 15 Concatenating SAS Data Sets: Execution na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 Concatenating SAS Data Sets: Execution na1 Name TORRES LANG SMITH Gender M F F JobCode NA1 NA1 NA1 na2 Name LISTER TORRES Name TORRES Gender JobCode M NA2 F NA2 na2 Name LISTER TORRES Name TORRES Gender JobCode M NA2 F NA2 data newhires; set na1 na2; run; Automatic return newhires Name TORRES LANG SMITH LISTER TORRES PDV Gender JobCode F NA2 Automatic output Gender M F F M F JobCode NA1 NA1 NA1 NA2 NA2 17 data newhires; set na1 na2; run; PDV Gender JobCode F NA2 End of File newhires Name TORRES LANG SMITH LISTER TORRES Gender M F F M F JobCode NA1 NA1 NA1 NA2 NA2 18 3 Concatenating SAS Data Sets: Execution When SAS reaches end-of-file on the last data set, DATA step execution ends. Business Task Two SAS data sets, fa1 and fa2, contain data for newly hired flight attendants. Concatenate the data sets into a new data set named newfa. newhires Name TORRES LANG SMITH LISTER TORRES Gender M F F M F JobCode NA1 NA1 NA1 NA2 NA2 fa1 Name KENT PATEL JONES Gender F M F JobCode FA1 FA1 FA1 fa2 Name LOPEZ GRANT JCode FA2 FA2 Gender F F The data sets contain similar data, but the variable names are different (JobCode versus JCode). 19 20 Concatenating SAS Data Sets: Compilation fa1 Name KENT PATEL JONES Gender F M F JobCode FA1 FA1 FA1 Name Concatenating SAS Data Sets: Compilation fa1 fa2 JobCode FA1 FA1 FA1 Name fa2 Name LOPEZ GRANT JCode FA2 FA2 Gender F F Name KENT PATEL JONES Gender F M F Name LOPEZ GRANT JCode FA2 FA2 Gender F F data newfa; set fa1 fa2; run; PDV Gender JobCode data newfa; set fa1 fa2; run; PDV Gender JobCode JCode Add additional variable 21 22 Concatenating SAS Data Sets: Compilation fa1 Name KENT PATEL JONES Gender F M F JobCode FA1 FA1 FA1 Name Concatenating SAS Data Sets: Execution fa1 fa2 JobCode FA1 FA1 FA1 Name fa2 Name LOPEZ GRANT JCode FA2 FA2 Gender F F Name KENT PATEL JONES data newfa; set fa1 fa2; run; Name PDV Gender JobCode JCode Gender F M F Name LOPEZ GRANT JCode FA2 FA2 Gender F F data newfa; set fa1 fa2; run; Name KENT PATEL JONES LOPEZ GRANT PDV Gender JobCode JCode newfa Gender JobCode JCode newfa Gender F M F F F JobCode JCode FA1 FA1 FA1 FA2 FA2 23 24 4 The RENAME= Data Set Option You can use a RENAME= data set option to change the name of a variable. General form of the RENAME= data set option: SAS-data-set(RENAME=(old-name-1=new-name-1 SAS-data-set(RENAME=(old-name-1=new-name-1 old-name-2=new-name-2 old-name-2=new-name-2 .. .. .. old-name-n=new-name-n)) old-name-n=new-name-n)) 25 The RENAME= Data Set Option fa1 Name KENT PATEL JONES Gender F M F JobCode Name FA1 LOPEZ FA1 GRANT FA1 fa2 JCode FA2 FA2 Gender F F data newfa; set fa1 fa2(rename=(JCode=JobCode)); run; PDV Name Gender JobCode 26 The RENAME= Data Set Option fa1 Name KENT PATEL JONES Gender F M F JobCode Name FA1 LOPEZ FA1 GRANT FA1 The RENAME= Data Set Option fa1 Name KENT PATEL JONES Gender F M F JobCode Name FA1 LOPEZ FA1 GRANT FA1 fa2 JCode FA2 FA2 Gender F F fa2 JCode FA2 FA2 Gender F F data newfa; set fa1 fa2(rename=(JCode=JobCode)); run; data newfa; set fa1 fa2(rename=(JCode=JobCode)); run; newfa PDV Name Gender JobCode PDV Name Gender JobCode 27 Name KENT PATEL JONES LOPEZ GRANT Gender F M F F F JobCode FA1 FA1 FA1 FA2 FA2 28 Interleaving SAS Data Sets Use the SET statement with a BY statement in a DATA step to interleave SAS data sets. General form of a DATA step interleave: DATA SAS-data-set; DATA SAS-data-set; SET SAS-data-set1 SAS-data-set2 .. ....;; SET SAS-data-set1 SAS-data-set2 BY BY-variable; BY BY-variable; <other SAS statements> <other SAS statements> RUN; RUN; The SORT Procedure (Review) When you use the BY statement, the data set must be sorted or indexed according to the BY variable(s). You can use the SORT procedure to sort the data. General form of a PROC SORT step: PROC SORT DATA=SAS-data-set1 PROC SORT DATA=SAS-data-set1 <OUT=SAS-data-set2>; <OUT=SAS-data-set2>; BY <DESCENDING> BY-variable ...; BY <DESCENDING> BY-variable ...; RUN; RUN; 29 30 5 Interleaving SAS Data Sets Interleaving SAS data sets simply concatenates SAS data sets so the observations in the resulting data set are in order. Interleaving SAS Data Sets Interleave the fa1 and fa2 data sets by Name. fa1 Name KENT PATEL JONES Gender F M F JobCode Name FA1 LOPEZ FA1 GRANT FA1 fa2 JCode FA2 FA2 Gender F F miamiemp ID Salary 109 36000 171 54000 The original data sets must be in order. data allemp; set miamiemp parisemp romeemp; by ID; run; allemp ID Salary 059 60000 083 87000 109 36000 154 88000 171 54000 217 42000 parisemp ID Salary 083 87000 217 42000 The data sets must be sorted first. proc sort data=fa1; proc sort data=fa2; by name; by name; run; run; Name JONES KENT PATEL Gender F F M JobCode Name FA1 GRANT FA1 LOPEZ FA1 romeemp ID Salary 059 60000 154 88000 JCode FA2 FA2 Gender F F 32 31 Interleaving SAS Data Sets fa1 Name JONES KENT PATEL Gender F F M JobCode Name FA1 GRANT FA1 LOPEZ FA1 Interleaving SAS Data Sets fa1 fa2 JobCode Name FA1 GRANT FA1 LOPEZ FA1 Name JONES KENT PATEL Gender F F M fa2 JCode FA2 FA2 Gender F F JCode FA2 FA2 Gender F F data newfa; set fa1 fa2(rename=(JCode=JobCode)); by Name; Which value comes first? run; data newfa; set fa1 fa2(rename=(JCode=JobCode)); by Name; Which value comes first? run; PDV Name GRANT GRANT Gender JobCode F FA2 Name GRANT newfa Gender JobCode F FA2 PDV Name JONES GRANT JONES Gender JobCode F FA1 FA2 Name GRANT JONES newfa Gender JobCode F FA2 F FA1 33 34 Interleaving SAS Data Sets fa1 Name JONES KENT PATEL Gender F F F JobCode Name FA1 GRANT FA1 LOPEZ FA1 fa2 JCode FA2 FA2 Gender F F data newfa; set fa1 fa2(rename=(JCode=JobCode)); by Name; run; Lab Exercises 12 Exercise 1 Concatenating SAS Data Sets PDV Name newfa Gender JobCode Name GRANT JONES KENT LOPEZ PATEL Gender F F F F M JobCode FA2 FA1 FA1 FA2 FA1 35 36 6 Merging SAS Data Sets You can read any number of SAS data sets with a single MERGE statement. SAS data sets The MERGE Statement You can use the MERGE statement to combine observations from two or more SAS data sets. General form of the MERGE statement with a BY statement: DATA SAS-data-set ... ;; DATA SAS-data-set ... MERGE SAS-data-set-1 SAS-data-set-2 ...; MERGE SAS-data-set-1 SAS-data-set-2 ...; BY BY-variable-1 ...; BY BY-variable-1 ...; <additional SAS statements> <additional SAS statements> RUN; RUN; 37 38 costs sales goals taxes data compare; merge costs sales goals taxes; by Month; run; compare costs sales goals taxes Match-Merge The most common type of merge is a match-merge, which uses a common variable to join observations. Match-Merging When you match-merge two or more data sets, it is possible to have repeated BY values non-matches. The data sets need to be sorted before match-merging. DATA Step 39 40 ID 1 3 4 A Name SAM SUE BOB DATA Step Merge data new; merge a b; by ID; run; NEW ID Name Age 1 SAM 31 2 42 3 SUE 4 BOB 21 ID 1 2 4 B Age 31 42 21 Business Task International Airlines is comparing monthly sales performance to monthly sales goals. The sales and goals data are stored in separate SAS data sets. 41 42 7 Business Task To calculate the difference between revenues and goals, the performance and goals data sets must be merged. Merging SAS Data: Compilation performance Month 1 2 3 Sales 2118223 1960034 2094220 goals Month 1 2 3 Goal 2130000 1920000 2130000 performance Month 1 2 goals Goal 2130000 1920000 Sales Month 2118223 1 1960034 2 Match-merge the data sets by Month and compute the difference between the variable values for Sales and Goal. Sales 2118223 1960034 data compare; merge performance goals; by Month; Difference=Sales-Goal; run; PDV Month N 8 43 44 compare Month 1 2 Goal Difference 2130000 -11777 1920000 40034 Merging SAS Data: Compilation performance Month 1 2 3 Sales 2118223 1960034 2094220 Merging SAS Data: Compilation performance Month 1 2 3 Sales 2118223 1960034 2094220 goals Month 1 2 3 Goal 2130000 1920000 2130000 goals Month 1 2 3 Goal 2130000 1920000 2130000 data compare; merge performance goals; by Month; Difference=Sales-Goal; run; data compare; merge performance goals; by Month; Difference=Sales-Goal; run; PDV Month N 8 Sales N 8 45 PDV Month N 8 Sales N 8 46 Merging SAS Data: Compilation performance Month 1 2 3 Sales 2118223 1960034 2094220 Merging SAS Data: Compilation performance Month 1 2 3 Sales 2118223 1960034 2094220 goals Month 1 2 3 Goal 2130000 1920000 2130000 goals Month 1 2 3 Goal 2130000 1920000 2130000 data compare; merge performance goals; by Month; Difference=Sales-Goal; run; data compare; merge performance goals; by Month; Difference=Sales-Goal; run; PDV Month N 8 Sales N 8 Goal N 8 47 PDV Month N 8 Sales N 8 Goal N 8 Difference N 8 48 8 Merging SAS Data: Compilation performance Month 1 2 3 Sales 2118223 1960034 2094220 Merging SAS Data: Execution performance Month 1 2 3 Sales 2118223 1960034 2094220 goals Month 1 2 3 Goal 2130000 1920000 2130000 Month 1 2 3 Goal 2130000 1920000 2130000 goals data compare; merge performance goals; by Month; Difference=Sales-Goal; run; data compare; merge performance goals; by Month; Difference=Sales-Goal; run; PDV Month N 8 Sales N 8 Goal N 8 Difference N 8 PDV compare Month N 8 Sales N 8 Goal N 8 Descriptor Difference portion N created 49 8 Month . Sales . Goal Difference . . 50 Initialize PDV to missing Merging SAS Data: Execution performance Month 1 2 3 Sales 2118223 1960034 2094220 Merging SAS Data: Execution goals performance Month 1 2 3 Sales 2118223 1960034 2094220 Month 1 2 3 Goal 2130000 1920000 2130000 Month 1 2 3 Goal 2130000 1920000 2130000 goals Which BY group comes first? data compare; merge performance goals; by Month; Difference=Sales-Goal; run; Month=1 Read 1 obs from each matching data set data compare; merge performance goals; by Month; Difference=Sales-Goal; run; PDV Month . Sales . Goal Difference . . 51 PDV Month . 1 Sales Goal Difference Difference . . . 2118223 2130000 . 52 Merging SAS Data: Execution performance Month 1 2 3 Sales 2118223 1960034 2094220 Merging SAS Data: Execution performance Month 1 2 3 Sales 2118223 1960034 2094220 Month 1 2 3 Goal 2130000 1920000 2130000 goals Month 1 2 3 Goal 2130000 1920000 2130000 goals data compare; merge performance goals; by Month; Difference=Sales-Goal; run; Automatic return PDV data compare; merge performance goals; by Month; Difference=Sales-Goal; run; Month Sales Goal Difference 1 2118223 2130000 -11777 Automatic output Month Sales Goal Difference 1 2118223 2130000 -11777 54 PDV Month 1 Sales Goal Difference 2118223 2130000 -11777 53 compare 9 Merging SAS Data: Execution performance Month 1 2 3 Sales 2118223 1960034 2094220 Merging SAS Data: Execution performance Month 1 2 3 Sales 2118223 1960034 2094220 Month 1 2 3 Goal 2130000 1920000 2130000 goals Month 1 2 3 Goal 2130000 1920000 2130000 goals Any obs remaining in current BY group? NO data compare; merge performance goals; by Month; Difference=Sales-Goal; run; data compare; merge performance goals; by Month; Difference=Sales-Goal; run; PDV Month 1 Sales Goal Difference 2118223 2130000 . 55 PDV Month 1 . Sales Goal Difference 2118223 2130000 . . . 56 Reinitialize new variables to missing Reinitialize rest of PDV to missing Merging SAS Data: Execution performance Month 1 2 3 Sales 2118223 1960034 2094220 Business Task Merge two data sets to acquire the names of the German crew who are scheduled to fly next week. End of File Month 1 2 3 Goal goals 2130000 1920000 2130000 End of File gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK gersched EmpID E04064 E00632 E01996 FlightNum 5105 5250 5501 data compare; merge performance goals; by Month; Difference=Sales-Goal; run; PDV Month 3 Sales Goal Difference 2094220 2130000 . compare Month 1 2 3 Sales Goal Difference 2118223 2130000 -11777 1960034 1920000 40034 2094220 2130000 -35780 To match-merge the data sets by EmpID, the data sets must be ordered by EmpID. proc sort data=gersched; by EmpID; run; 57 58 ... Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK EmpID E00632 E01996 E04064 FlightNum gersched 5250 5501 5105 Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK EmpID E00632 E01996 E04064 FlightNum 5250 5501 5105 gersched First BY Group: EmpID=E00632 Read 1 obs from each matching data set for first BY group data nextweek; merge gercrew gersched; by EmpID; run; data nextweek; merge gercrew gersched; by EmpID; run; PDV EmpID LastName FlightNum PDV EmpID E00632 LastName STRAUSS FlightNum 5250 Initialize PDV to missing 59 60 10 Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK EmpID E00632 E01996 E04064 FlightNum gersched 5250 5501 5105 Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK EmpID E00632 E01996 E04064 FlightNum gersched 5250 5501 5105 Any obs remaining in current BY group? NO Automatic return PDV data nextweek; merge gercrew gersched; by EmpID; run; EmpID E00632 EmpID E00632 data nextweek; merge gercrew gersched; by EmpID; run; LastName STRAUSS LastName STRAUSS FlightNum 5250 FlightNum 5250 PDV EmpID E00632 LastName STRAUSS FlightNum 5250 Automatic output Reinitialize PDV to missing 61 62 nextweek Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 Next BY Group: EmpID=E01483 Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK EmpID E00632 E01996 E04064 FlightNum gersched 5250 5501 5105 EmpID E00632 E01996 E04064 FlightNum gersched 5250 5501 5105 Read 1 obs from each matching data set for next BY group data nextweek; merge gercrew gersched; by EmpID; run; Automatic return PDV data nextweek; merge gercrew gersched; by EmpID; run; EmpID E01483 EmpID E00632 E01483 LastName SCHELL-HAUNGS LastName STRAUSS SCHELL-HAUNGS FlightNum PDV EmpID E01483 LastName SCHELL-HAUNGS FlightNum Automatic output nextweek 63 FlightNum FlightNum 5250 5250 64 Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK EmpID E00632 E01996 E04064 FlightNum 5250 5501 5105 gersched EmpID E00632 E01996 E04064 FlightNum 5250 5501 5105 gersched Any obs remaining in current BY group? NO Next BY Group: EmpID=E01996 Read 1 obs from each matching data set for next BY group data nextweek; merge gercrew gersched; by EmpID; run; data nextweek; merge gercrew gersched; by EmpID; run; PDV EmpID E01483 LastName SCHELL-HAUNGS FlightNum PDV EmpID E01996 LastName WELLHAEUSSER FlightNum 5501 Reinitialize PDV to missing 65 66 11 Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK EmpID E00632 E01996 E04064 FlightNum 5250 5501 5105 Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK EmpID E00632 E01996 E04064 FlightNum 5250 5501 5105 gersched gersched Any obs remaining in current BY group? NO Automatic return PDV data nextweek; merge gercrew gersched; by EmpID; run; EmpID E01996 EmpID E00632 E01483 E01996 data nextweek; merge gercrew gersched; by EmpID; run; LastName WELLHAEUSSER LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER FlightNum 5501 FlightNum 5250 5501 67 Automatic output PDV EmpID E01996 LastName WELLHAEUSSER FlightNum 5501 nextweek Reinitialize PDV to missing 68 Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK EmpID E00632 E01996 E04064 FlightNum 5250 5501 5105 Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK gersched EmpID E00632 E01996 E04064 FlightNum 5250 5501 5105 gersched Next BY Group: EmpID=E04064 Read 1 obs from each matching data set for next BY group data nextweek; merge gercrew gersched; by EmpID; run; Automatic return PDV data nextweek; merge gercrew gersched; by EmpID; run; EmpID E04064 LastName WASCHK FlightNum 5105 PDV EmpID E04064 LastName WASCHK FlightNum 5105 Automatic output nextweek 69 EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK FlightNum 5250 5501 5105 70 Merging SAS Data: Execution gercrew EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK EmpID E00632 E01996 E04064 FlightNum 5250 5501 5105 gersched End of File End of File data nextweek; merge gercrew gersched; by EmpID; run; Lab Exercises 12 Exercise 2 Merging SAS Data Sets PDV EmpID E04064 LastName WASCHK FlightNum 5105 nextweek EmpID E00632 E01483 E01996 E04064 LastName STRAUSS SCHELL-HAUNGS WELLHAEUSSER WASCHK FlightNum 5250 5501 5105 71 72 12 ...
View Full Document

This note was uploaded on 10/31/2011 for the course STAT 440 taught by Professor Muyot,m during the Fall '08 term at University of Illinois, Urbana Champaign.

Page1 / 12

notes13 - Concatenating SAS Data Sets Use the SET statement...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online