+ Reply to Thread
Results 1 to 2 of 2

Thread: Generating month and year from Sas date

  1. #1
    IBM Rules
    Points: 12,856, Level: 74
    Level completed: 2%, Points required for next Level: 394

    Posts
    2,502
    Thanks
    110
    Thanked 368 Times in 356 Posts

    Generating month and year from Sas date



    I have a Sas field with days, months, and years in it. I want to create a field with only a month and year in it (no days). I know how to pull year out and month (seperately) but not how to pull both month and year out at the same time.

    I know I can create one field for month and one for year and then combine them, but I am trying to avoid that option.
    "Facts are stubborn things, but statistics are more pliable." Mark Twain

  2. #2
    TS Contributor
    Points: 6,808, Level: 54
    Level completed: 29%, Points required for next Level: 142

    Posts
    775
    Thanks
    0
    Thanked 70 Times in 69 Posts

    Re: Generating month and year from Sas date


    The best suggestion I can come up with for now is to specify the format MONYY7.

    Do you want to do something with the variable that has month/year value? Or do you just want to display it?

    I want to say you can't make a variable that has just the month/year value, because SAS wouldn't understand it. eg 5/25/2012 has the value 19138 in SAS, while 5/24/2012 has the value 19137. Can't just say 5/2012. But there's ways to work around this.

    Why can't you just pull the month and year and work with those variables jointly?

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats