Sample SAS Script

libname cihilib 'E:\CIHI_GSDAP_APP_Package\Data\Data\'; data cihi; set cihilib.hsing_nacrs_07; proc contents data = cihi; title 'Contents of data set'; run; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = libname cihilib 'E:\CIHI_GSDAP_APP_Package\Data\Data\'; data cihi; set cihilib.hsing_nacrs_07; proc print data = cihi (obs=50); /*(firstobs=20 obs=50)*/ title 'first 50 observations'; run; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Notes: /* OBS specifies the last observation of the SAS data set that will be printed. It does NOT specify how many observations that should be printed. If you wanted to begin printing at the 20th observation and end at the 50th observation you can use the firstobs option */ /* The proc print expects the data to be in order (ascending) of the BY variable. If your data is in descending order you can use by descending deid_inst_num */ = = = = = = = = = = = = = = = = = = = = = = = = = = = = = /* this program displays first 5 obs of each institute */ libname cihilib 'E:\CIHI_GSDAP_APP_Package\Data\Data\'; data cihi; set cihilib.hsing_nacrs_07 (keep deid_inst_num DATE_PHYSICAN_INIT_ASSESSMENT TIME_PHYSICAN_INIT_ASSESSMENT); proc sort data = cihi; by deid_inst_num; run; data cihi; set cihi; by deid_inst_num; if first.deid_inst_num then num=0; num+1; run; /* new variable num that index from 1 to n_sub_i by each institute */ data cihi_first_5; set cihi; if num < 6; run; /* pick out first 5 obs for each institute and store in new sas data set */ proc print data = cihi_first_5; var deid_inst_num num; run; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = libname cihilib 'E:\CIHI_GSDAP_APP_Package\Data\Data\'; data cihi; set cihilib.hsing_nacrs_07 (keep deid_inst_num DATE_OF_REGISTRATION REGISTRATION_TIME DATE_PHYSICAN_INIT_ASSESSMENT TIME_PHYSICAN_INIT_ASSESSMENT DATE_VISIT_COMPLETED); proc sort data = cihi; by deid_inst_num; run; data cihi; set cihi; if first.deid_inst_num then dum_id=0; dum_id+1; run; /* generate dummy id sequence from 1 to number of total obs */ data cihi; set cihi; by dum_id; if (TIME_PHYSICAN_INIT_ASSESSMENT=9999 or TIME_PHYSICAN_INIT_ASSESSMENT=' ') then dum1=0; else dum1=1; if (PATIENT_LEFT_ED_TIME=9999 or PATIENT_LEFT_ED_TIME=' ') then dum2=0; else dum2=1; dum3 = dum1*dum2; run; /* create dummy variable dum1 to indicate which obs has missing value TIME_PHYSICAN_INIT_ASSESSMENT, dummy variable dum2 to indicate which obs has missing value PATIENT_LEFT_ED_TIME, dummy variable dum3 to indicate which obs has missing value product of dum1 x dum2 */ proc freq data = cihi; by deid_inst_num; title 'FREQ of Missing TIME_PHYSICAN_INIT_ASSESSMENT by Institute'; tables dum1; /* creating frequency table of the variable TIME_PHYSICAN_INIT_ASSESSMENT by Institute*/ run; proc freq data = cihi; title 'FREQ of Missing TIME_PHYSICAN_INIT_ASSESSMENT by Institute'; tables dum1*deid_inst_num; /* creating frequency cross-table of the variable TIME_PHYSICAN_INIT_ASSESSMENT by Institute*/ run; proc freq data = cihi; title 'FREQ of Missing PATIENT_LEFT_ED_TIME by Institute'; tables dum2*deid_inst_num; /* creating frequency cross-table of the variable PATIENT_LEFT_ED_TIME by Institute*/ run; proc freq data = cihi; title 'FREQ of Missing TIME_PHYSICAN_INIT_ASSESSMENT x PATIENT_LEFT_ED_TIME by Institute'; tables dum3*deid_inst_num; /* creating frequency cross-table of the variables TIME_PHYSICAN_INIT_ASSESSMENT x PATIENT_LEFT_ED_TIME by Institute*/ run; proc means sum nway data = cihi; class deid_inst_num; var dum1; output out=Number_of_missing_init_assessment_time sum=dum1; run; /* Calculate the total obs and number of missing TIME_PHYSICAN_INIT_ASSESSMENT obs by Institute */ = = = = = = = = = = = = = = = = = = = = = = = = = = = = = libname cihilib 'E:\CIHI_GSDAP_APP_Package\Data\Data\'; data cihi; set cihilib.hsing_nacrs_07 (keep DATE_OF_REGISTRATION REGISTRATION_TIME DATE_PHYSICAN_INIT_ASSESSMENT TIME_PHYSICAN_INIT_ASSESSMENT DATE_VISIT_COMPLETED); if deid_inst_num=51155; /* work only with institution 51155 */ proc print data = cihi; title 'observations of deid_inst_num=51155'; proc FREQ data = cihi; title 'frequency of Initial Assessment Time'; tables TIME_PHYSICAN_INIT_ASSESSMENT; /* creating frequency table of the variable TIME_PHYSICAN_INIT_ASSESSMENT */ run; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = libname cihilib 'E:\CIHI_GSDAP_APP_Package\Data\Data\'; data cihi; set cihilib.hsing_nacrs_07 (keep deid_inst_num DATE_OF_REGISTRATION REGISTRATION_TIME DATE_PHYSICAN_INIT_ASSESSMENT TIME_PHYSICAN_INIT_ASSESSMENT DATE_VISIT_COMPLETED; proc sort data = cihi; by deid_inst_num; run; proc FREQ data = cihi; by deid_inst_num; title 'FREQ of Missing TIME_PHYSICAN_INIT_ASSESSMENT'; tables TIME_PHYSICAN_INIT_ASSESSMENT; /* creating frequency table of the variable TIME_PHYSICAN_INIT_ASSESSMENT */ run; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = data Erlin_ED; infile 'E:\Erlin_data.csv' dlm=',' dsd LRECL=10000 TRUNCOVER; /*read Erlin_data.csv into SAS*/ INPUT Arr_Triage Depar_Triage Var3 Var4 T_Time Combined_Depar_Triage Arrival_Dum_1 Arrival_Dum_2 Dept_Dum_1 Dept_Dum_2 Var11 Arrival_Dum_1xDept_Dum_1 Arrival_Dum_1xDept_Dum_2 Arrival_Dum_2xDept_Dum_1 Arrival_Dum_2xDept_Dum_2; /*Input Variable Names*/ proc contents data=Erlin_play2; title 'data contents of Erlin_play2 Data'; proc means data=Erlin_play2; /*Means of T_Time by Arrival Triage Score and by Re-assessed Acuity*/ var T_Time; by Arr_Triage Combined_Depar_Triage; run; = = = = = = = = = = = = = = = = = = = = = = = = = = = = =