Hi All,
I wanted to check if fields are populated based on the criteria. If a field is not populated, then add error_message to indicate the related criterium. For example, in the data I have below, first_name is a field required according to the file "have_ck". When first_name is not populated, the related error_message will need to be added to the original file, as the dummy data "want" shows. Any insight is greatly appreciated!
data have; infile datalines truncover dsd; input dummyid first_name $ middle_name $ last_name $ DOB :mmddyy10.; format DOB mmddyy10.; datalines; 1 ,Joe , ,Messi ,1/2/1960 2 , ,S ,Bieber ,4/3/1958 3 ,Jenny , , ,5/5/1955 ; run;
data have_ck; infile datalines truncover dsd; length field $11. error_message $25.; input field $ required error_message $; datalines; dummyid,1,[dummyid] is required. first_name,1,[first_name] is required. middle_name,0, last_name,1,[last_name] is required. DOB,1,[DOB] is required. ; run;
data want; infile datalines truncover dsd; length error_message $25.; input dummyid first_name $ middle_name $ last_name $ DOB :mmddyy10. error_message $; format DOB mmddyy10.; datalines; 1 ,Joe , ,Messi ,1/2/1960 , 2 , ,S ,Bieber ,4/3/1958 ,[first_name] is required. 3 ,Jenny , , ,5/5/1955 ,[last_name] is required. ; run;
... View more