sdemas45
Feb 10, 2008, 01:15 PM
I am working with a data set that I would like to link with another data set. However, I need to do two thing before linking the two data set together. One is that I have a variable claim that I need to format. The variable has values 250, 5525 etc and I need to place a period to make it 2.50, 55.25, etc. What SAS code to use to make it two decimal places? Secondly, I have the date in julian format like January 20, 2008 in this format "20080120"and I would to change to 02/20/2008. What SAS code to use to accomplish these two formating so that I can link the data set? Thanks for any help.
dan70m1
Feb 12, 2008, 04:03 PM
Hi,
Firstly you don't say what type your "claim" field is? Char/num? For the purpose of the example, I will assume the values of 250, 5525 are stored as numbers. To convert to floating point values, simply divide by 100! If they are stored as CHAR then use:
x="250";
y="5525";
x2=input(x,best.)/100;
y2=input(y,best.)/100;
For your date question, I will assume that your value of "20080120" is stored as a character string. To convert this to a number, try :
attrib dt format=mmddyy10.;
z="20080120";
dt=mdy(input(substr(z,5,2),2.),input(substr(z,7,2) ,2.),input(substr(z,1,4),4.));
the attrib statement will format your date correctly as you specified.
Hope this helps
D
pmk123
Sep 26, 2012, 01:53 AM
For the first question,if the variable is num and when you simple divide by 100,it does not work..
The zeros are missing at the end.
For ex:
250/100 gives you a 2.5 and not a 2.50
Can anyone answe this question.