I have a dataset in which the social security number names the variable soc is in the format 55555555. But I need it to be the usually for
I suspect your variable SOC is character. It needs to be a number to apply the SSN format:
data want;
set have (obs= 10);
socialsecurity=input(soc, best12.);
format socialsecurity ssn11.;
put socialsecurity = ;
run;
is there another way to apply the dashes through a function procedure?
I figured it our thankyou needs the input and put function.
You can also try the perl regular expression incase you havent tried the code i posted.
Please try the below untested code
data have;
x='555555555';
y=prxchange('s/(\d{3,3})(\d{2,2})(\d{4,4})/$1-$2-$3/',-1,x);
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.