**** *Instructions for random number generation for medical records: -Enter the filepath, including file name, for the medical record line list. -Do not use any apostrophes or quotations in the path. -Be sure the line list's file type is an .xlsx and that this is included in the path's file name below. -Review variable names on your line list to ensure they match with this program. The following fields (not case-sensitive) are used to generate a random number and episode of care (EoC) number: -MRN -AdmissionDate; *If the HAI being validated does not need an EoC number, you can delete lines 32-33 of this program. There are comments at these lines for reference.; ****; *Enter file path here.; %let recordpath = C:\folder path\HAI LineList Name.xlsx; proc import out = recordlist datafile = "&recordpath" dbms = xlsx replace; run; proc sort data=recordlist;where mrn ne ""; by mrn AdmissionDate; data recordlist2; set recordlist; by mrn AdmissionDate; /*Remove this line if EoC field is not needed.*/ EoC+first.AdmissionDate; /*Remove this line if EoC field is not needed.*/ run; proc sql noprint; select count(*) into :rn from recordlist2; quit; data recordlist3; set recordlist2; do i = 1 to &rn; randnum = rand("integer",0,100000); end; drop i; run; proc sort data=recordlist3 out=FinalRecordList; by randnum; run; data _null_; call symput("rname", scan("&recordpath",-1,"\")); run; data _null_; call symput("rOut", tranwrd("&recordpath","&rname", "Record Line List with RandNum.xlsx")); run; proc export data=FinalRecordList outfile= "&rOut" dbms=xlsx replace; run; *"FinalRecordList" if the final medical record line list with a random number assigned. This data set has now been exported to the same path as the original line list and named "Record Line List with RandNum.xlsx";