/*==============================*/ /* CREATING PERMANENT DATA SETS */ /*==============================*/ /*This is an option statement that identifies the data library and the computer directory in which to store your permanent data set*/ LIBNAME mylib 'C:/mysubdirectory' /*This is the first line of a data step that creates a permanent data set*/ DATA mylib.newnurse; /*NOTE: The default (and temporary) library is called WORK, so you can refer to an ordinary temporary data set as newnurse or work.newnurse*/ /*==================================================*/ /* CREATING A NEW DATA SET BASED ON AN OLD DATA SET */ /*==================================================*/ /*This is a data step command that creates a new data set called newnurse that recalls one already-created data set called nurseone*/ DATA newnurse; SET nursingl; /*This is a data step command that creates a new data set called newnurse that recalls two already-created data sets (called nurseone and nursetwo) then combines them as if they contain different observations from the same study*/ DATA allnurse; SET nursingl nursings; /*This is a data step command that creates a new data set called newnurse that recalls two already-created data sets (called nurseone and nursetwo) then combines them as if they contain different information about the same patients, each of whom have a unique patient id stored in the variable patid*/ DATA newnurse; MERGE nursingl nursings; BY PARTNERID; /*====================================*/ /* FORMATTING AND LABELING A DATA SET */ /*====================================*/ /*This is a data step command that labels variables*/ LABEL BEDS="number of beds in home" MCDAYS="annual medical in-patient days (hundreds)" TDAYS="annual total patient days (hundreds)" PCREV="annual total patient care revenue ($hundreds)" NSAL="annual nursing salaries ($hundreds)" FEXP="annual facilities expenditures ($hundreds)"; /*This procedure step creates a format for the rural variable*/ PROC FORMAT; VALUE RURAL 0="URBAN" 1="RURAL"; VALUE BEDS 25="SMALLEST"; RUN; /*This is a data step command that applies an already-created format to a variable - note the period following a format name*/ FORMAT RURAL RURAL. BEDS BEDS.; /*====================================*/ /* SELECTING ONLY PARTS OF A DATA SET */ /*====================================*/ /*This is a data step command that keeps only the listed variables in your data set - from this point on these are the only variables that will be available to you*/ KEEP PCREV BEDS; /*This is a data step command that drops the listed variables*/ DROP FEXP; /*This is a data step command that KEEPS only those observations that satisfy the test*/ IF RURAL=1; /*This is a data step command that DELETES only those observations that satisfy the test*/ IF RURAL=1 then DELETE; /*========================*/ /* CREATING NEW VARIABLES */ /*========================*/ /*This is a data step command that creates a variable CONST that is always 1*/ CONST=1; /*This is a data step command that creates a variable REVPBED from other variables in the data set*/ REVPBED = PCREV/BEDS; /*This is a data step command that creates a variable SIZE based on another variable in the data set*/ IF BEDS < 40 then SIZE=1; IF BEDS >= 40 & BEDS < 120 then SIZE=2; IF BEDS >= 120 then SIZE=3; IF BEDS = . then SIZE=.; /*This is a data step command that does the same as above, but different syntax*/ IF BEDS = . then SIZE = .; ELSE IF BEDS < 40 then SIZE=1; ELSE IF BEDS < 120 then SIZE=2; ELSE SIZE=3;