BookmarkSubscribeRSS Feed
Sanjeev
Fluorite | Level 6

In a SAS VA calculation, how can one convert an integer field to character. 

Say for example I'd like to build a fiscal year off a given data. I have the integer  years 2013, 2014 and would like to concatenate them to be "2013-214"

I'm using SAS VA 7.1

6 REPLIES 6
TejaSurapaneni
Lapis Lazuli | Level 10

Hi Sanjeev..

Image - 2.pngIMAGE - 1.png

I hope this will help You,

Thanks & Regards,

Teja Surapaneni

Sanjeev
Fluorite | Level 6

Hi Teja,

This might help but could you send me the code itself...? As opposed to the Visual view.

Thank you,

Sanjeev

TejaSurapaneni
Lapis Lazuli | Level 10

Hello Sanjeev,

Here It is

1.png

You can also take dates instead of years.  financial year.  i.e.,  1st April'14 - 31st March'15 (2014-2015).

Thanks & Regards,

Teja Surapaneni.

Sanjeev
Fluorite | Level 6

Hi Teja,

This does not help. I would like to dynamically create the fiscal year - not hard code the return values. 

Here's how I would like to write the code:

if Month(DatePart('PS_Record_DateEffective'n )) in (1,2,3)  Return

   ToChar(Year(DatePart('PS_Record_DateEffective'n ))-1) +'-'+ ToChar(Year(DatePart('PS_Record_DateEffective'n ))

else

   ToChar(Year(DatePart('PS_Record_DateEffective'n ))) + '-'+ToChar(Year(DatePart('PS_Record_DateEffective'n )+1)

I just need a replacement for the ToChar function

Sanjeev

TejaSurapaneni
Lapis Lazuli | Level 10

Hi Sanjeev,

You can't create character fiscal year in sas va.

If you want alternative, you can refer below (hard coded).

Using this method u can calculate future fiscal years.

2.png3.png

Thanks & Regards

Teja Surapaneni

Sanjeev
Fluorite | Level 6

Okay, Thank you.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1379 views
  • 3 likes
  • 2 in conversation