+ Reply to Thread
Results 1 to 2 of 2

Thread: Generating month and year from Sas date

  1. #1
    IBM Rules
    Points: 12,754, Level: 73
    Level completed: 76%, Points required for next Level: 96

    Posts
    2,485
    Thanks
    108
    Thanked 365 Times in 353 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,779, Level: 54
    Level completed: 15%, Points required for next Level: 171
    Awards:
    Master Tagger

    Posts
    774
    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