Ask Experts Questions for FREE Help !
Ask
    sdemas45's Avatar
    sdemas45 Posts: 1, Reputation: 1
    New Member
     
    #1

    Feb 10, 2008, 01:15 PM
    SAS code to Format decimal places and julian date
    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's Avatar
    dan70m1 Posts: 2, Reputation: 1
    New Member
     
    #2

    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's Avatar
    pmk123 Posts: 1, Reputation: 1
    New Member
     
    #3

    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.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Calculating pi to n decimal places [ 5 Answers ]

Suppose your goal is to calculate (not look up) a value of pi that is accurate to n decimal places. Suppose n were 10. How would you do it?

Pi by recursive decimal places [ 5 Answers ]

I would like to know if there is a way to calculate pi by using the current last decimal place to calculate the next decimal place. I already made a formula for pi that I posted on another board, but someone suggested I copy here. ---Begin quote--- This doesn't really fit anywhere so I'm just...

Julian Beever [ 4 Answers ]

http://www.enkidu.cx/stumble/beever/ http://users.skynet.be/J.Beever/pave.htm Are these amazing or what?

Wrong date format I can't change. [ 8 Answers ]

I'm using MS Works 8.5. When I click on Format/Number/Date the exact format I want is not shown and the preview is often different from that. i.e. it shows as say 31/8/07 and I want 8/31/07 as I'm in Australia. How can I change it to what I want? Help would be much appreciated. Stuartp77


View more questions Search