I have string with variable names and text embedded in it and all variable names are embedded in square brackets. While concatenating need to cross check the result values present in the variable. In case of multiple results, these should be concatenated using comma (addition of “and” before the last entry only). Variables are combination of character and numeric.
For example If A , B present then concatenation should be A and B. If 3 results are present result should be A, B and C .
text="The details of the student are (values=[NAME] [SEX] [AGE] [HEIGHT] [WEIGHT]).";
data class; set sashelp.class; /* scenarios to be considered*/ if name="Alice" then do ;call missing(height,weight);end; if name="John" then do ; call missing(sex,age);end; if name="Carol" then do ; call missing(age, height, weight) ;end; ab=catx(',',name,sex, age, height, weight) ; run ;
output should be as below. The details of the student are Alfred,F,14,69 and 12.5. The details of the student are John,59 and 99.5. The details of the student are Carol and F.
Any suggestion or sample code how to get the required output.
... View more