finished Code
*Lab 8 – Problem 2;
title "Building an ID number from data";
data lab.ssn_number;
set lab.one;
ssn2 = compress(ssn, '-');
ssn3 = input(ssn2, ??11.);
drop ssn2;
run;
proc print data=lab.ssn_number;
run;
The code you shared doesn't have much to do with solving problems 1 to 5.
To support homework forum members normally want to see some of your own effort and then help with the bits where you get really stuck after you first tried yourself.
Hint: When you have text values with a delimiter such as - that usually appears in SSN then SCAN is useful tool to get the nth element of the value
Hint2: NEVER input parts of character values to numeric if the instruction is to Concatenate. You will lose leading zeroes and add complication to the code for concatenating.
Personally I consider #3 to be dangerous in terms of actual use. Discuss this with your instructor.
Suppose you have two values before removing blanks that look like this (because you created a numeric value from SSN of 0078 that becomes 78 for example)
' 1 2 12 5678'
'12 12 56 78'
If you remove blanks you get
'12125678' '12125678'
Unless your codes for things like Clinic and your month always uses 2 digits (and years REALLY should use 4 digits, look up Y2K) you have a possibility of creating duplicate values that should mean different things. Of course I do not have any of your data to see how likely this is but is something to be aware of.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.