Exploring, modeling, predicting and reporting with SAS Visual Analytics and SAS Visual Statistics

Concatenating two date values

Accepted Solution Solved
Reply
Contributor
Posts: 31
Accepted Solution

Concatenating two date values

Hi,

I am facing a challenge in getting two date values like Year and Week to be concatenated as YearWeek.

 

For example:

Year=2015

Week number = 1 To 52

Result needed is  a new varaible "Year_Weeknumber" = 201501, 201502 etc. in this format, displaying year and week number.

 

I have the year and weeknumber calculated in SAS from dates, but unable to concatenate them.

I am able to have yearMonth, YearQuarter values from date using Format, but did not find  "Year Weeknumber" option there.

 

Regards,

Abhi


Accepted Solutions
Solution
‎03-22-2016 08:13 AM
Grand Advisor
Posts: 16,348

Re: Concatenating two date values

If numeric use math

var=year*100+week;

 

if if you want a Character use catt

 

var=catt(year, put(week, z2.));

View solution in original post


All Replies
Solution
‎03-22-2016 08:13 AM
Grand Advisor
Posts: 16,348

Re: Concatenating two date values

If numeric use math

var=year*100+week;

 

if if you want a Character use catt

 

var=catt(year, put(week, z2.));

Contributor
Posts: 31

Re: Concatenating two date values

Thank you so much Reeza..It works !!!

Post a Question
Discussion Stats
  • 2 replies
  • 313 views
  • 0 likes
  • 2 in conversation