- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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*/
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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*/
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, it worked perfectly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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