Hi there,
I am working in SAS studio for SAS On Demand. I am working on a project for class and need help adding in dashes in place of missing values for the variable 'Inits'. Some of the observations have missing middle initials and they are blanks, one example is observation #6 below, and I need those to be dashes. I have attached the original dataset, along with my code to manipulate it, and a screenshot of the results.
Code:
DATA Utah; retain SSN Inits City StateCd ZipCd; SET Records (rename = (Inits = Initsold CitySt = StateCd)); ID1 = put(ID, Z9.); SSN = catx('-', SUBSTR(PUT(ID1, Z9.), 1, 3), SUBSTR(PUT(ID1, Z9.), 4, 2), SUBSTR(PUT(ID1, Z9.), 6, 4)); ZipCd = put(Zipcode, Z5.); City = scan(StateCd, 1, ','); Inits = compress(Initsold,'.'); ***note: how would I add in a dash for missing middle initial?; drop ID ID1 Zipcode Initsold GenderCode EthnicityCode RaceCode BirthYear BirthMonth BirthDay; RUN;
Please let me know if anyone knows what to do! Thank you!
Sincerely,
Kaitlin E Buck
... View more