BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DavidPhillips2
Rhodochrosite | Level 12

When I set month to fiscal month it saves correctly to the datastep but when I use fiscal_month in a concatenation it uses the value not the format.  The format alone works correctly.

 

How can I save the formatted value to the data table.  In this case I am trying to save to Fiscal Period Year.

 

My dataset ends up looking like 20157 rather than 201501.

 

PROC FORMAT;

     value Fiscal_Period_Format

     1='07'

     2='08'

     3='09'

     4='10'

     5='11'

     6='12'

     7='01'

     8='02'

     9='03'

     10='04'

     11='05'

     12='06';

RUN;

 

data ProposalsCombined; set P1;

    

     format Fiscal_Period Fiscal_Period_Format.;

     if(month(Submit_date) >= 7) then

           Fiscal_Year = year(datepart(Submit_Date));

     else

           Fiscal_Year = year(datepart(Submit_Date)) + 1;

     Fiscal_Period = month(datepart(Submit_Date)); /*this works*/

     Fiscal_period_Year = trim(left(Fiscal_Year)) || trim(left(Fiscal_Period)); /*this does not format*/

run;

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

As its a string you need to "put" the value into its format:

 Fiscal_period_Year = trim(left(Fiscal_Year)) || trim(left(put(Fiscal_Period,fiscal_period_format.))); /*this does not format*/

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

As its a string you need to "put" the value into its format:

 Fiscal_period_Year = trim(left(Fiscal_Year)) || trim(left(put(Fiscal_Period,fiscal_period_format.))); /*this does not format*/

DavidPhillips2
Rhodochrosite | Level 12

Thanks, it worked perfectly.

PaigeMiller
Diamond | Level 26

Concatenate (and all other functions) uses the actual value, not the formatted value.

 

You want

 

Fiscal_period_Year = trim(left(Fiscal_Year)) || trim(left(put(Fiscal_Period,fiscal_period_format.)));

 

or better yet

 

fiscal_period_year=cats(fiscal_year,put(Fiscal_Period,fiscal_period_format.));
--
Paige Miller

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 7417 views
  • 3 likes
  • 3 in conversation