Variable attributes permanent variable attributes

Info icon This preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: Examine the descriptor portion of the st.dfwlax data set. proc contents data=st.dfwlax; run; The SAS System Partial Output Obs Alphabetic List of Variables and Attributes # Variable Type Len 2 3 5 4 1 Date Dest Economy FirstClass Flight Num Char Num Num Char 8 3 8 8 3 Format Label MMDDYY10. Destination Economy Passengers First Class Passengers Flight 1 2 3 4 5 6 7 8 9 10 439 921 114 982 439 982 431 982 114 982 Date 12/11/2000 12/11/2000 12/12/2000 12/12/2000 12/13/2000 12/13/2000 12/14/2000 12/14/2000 12/15/2000 12/15/2000 Destination First Class Passengers Economy Passengers LAX DFW LAX dfw LAX DFW LaX DFW LAX DFW 20 20 15 5 14 15 17 7 . 14 137 131 170 85 196 116 166 88 187 31 21 22 Override Permanent Attributes Use a FORMAT statement in a PROC step to temporarily override the format stored in the data set descriptor. Lab Exercises 6 proc print data=st.dfwlax label; format Date date9.; run; Exercise 2: Assigning Variable Attributes 23 24 6 Override Permanent Attributes The DATASETS Procedure The SAS System Obs Flight 1 2 3 4 5 6 7 8 9 10 439 921 114 982 439 982 431 982 114 982 Date 11DEC2000 11DEC2000 12DEC2000 12DEC2000 13DEC2000 13DEC2000 14DEC2000 14DEC2000 15DEC2000 15DEC2000 Destination First Class Passengers LAX DFW LAX dfw LAX DFW LaX DFW LAX DFW 20 20 15 5 14 15 17 7 . 14 You can use the DATASETS procedure to modify a variable’s • name • label • format • informat. Economy Passengers 137 131 170 85 196 116 166 88 187 31 25 The DATASETS Procedure 26 Data Set Contents General form of PROC DATASETS for changing variable attributes: Use the DATASETS procedure to change the name of the variable Dest to Destination. PROC DATASETS LIBRARY=libref ; MODIFY SAS-data-set ; RENAME old-name-1=new-name-1 <. . . old-name-n=new-name-n>; LABEL variable-1='label-1' <. . . variable-n='label-n'>; FORMAT variable-list-1 format-1 <. . . variable-list-n format-n>; INFORMAT variable-list-1 informat-1 <. . . variable-list-n informat-n>; RUN; Look at the attributes of the variables in the st.dfwlax data set. proc contents data=st.dfwlax; run; Alphabetic List of Variables and Attributes # Type Len 2 3 5 4 1 27 Variable Date Dest Economy FirstClass Flight Num Char Num Num Char 8 3 8 8 3 28 7 The DATASETS Procedure Data Set Contents Look at the attributes of the variables in the st.dfwlax data set after running PROC DATASETS. Rename the variable Dest to Destination. proc datasets library=st; modify dfwlax; rename Dest=Destination; run; proc contents data=st.dfwlax; run; Alphabetic List of Variables and Attributes # 29 Variable Type Len 2 3 5 4 1 Date Destination Economy FirstClass Flight Num Char Num Num Char 8 3 8 8 3 30 8...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern