Hi..
I am trying to use Monname3. format in my program but it is not working properly.
Here i am giving small example..
data test;
format month monname3.;
input month amount;
cards;
9 1500
2 8200
3 3256
4 7412
5 2125
6 2536
;
run;
If i run this code i am getting output like this..
Obs month amount
1 Jan 1500
2 Jan 8200
3 Jan 3256
4 Jan 7412
5 Jan 2125
6 Jan 2536
It is showing every month as Jan...
any one could you please help me in that...
Regards..
Sanjeev.K
MONNAME. formats a DATE, not a month number.
data _null_;
x=today();
put x monname3.;
run;
Oh thanks Tom..
Is there any way to display month names instead of number in my above example(Except PROC FORMAT)???
Thanks..
Sanjeev.K
Hi,
I guess Monname format writes date values as name of the month,but you data don't have any date column.
If your data comes in the same format as you have mentioned then you can define user defined format and then apply on the month variable.
Thanks,
Shiva
data test(drop=mon);
format month monname3.;
input mon amount;
month=mdy(mon,1,2012);
cards;
9 1500
2 8200
3 3256
4 7412
5 2125
6 2536
;
run;
proc print;run;
Obs month amount
1 Sep 1500
2 Feb 8200
3 Mar 3256
4 Apr 7412
5 May 2125
6 Jun 2536
Well, I hardly disagree with LinLin, but this time will be an exception. I don't feel comfortable that her code actually made a change to your data, not just the format, I am not sure if that is exactly what you want. It will work if just for the report purpose, otherwise, you need to make your own format for it,luckily we only have 12 month, so it is not too bad:
proc format;
value mon
1='Jan'
2='Feb'
3='Mar'
4='Apr'
5='May'
6='Jun'
7='Jul'
8='Aug'
9='Sep'
10='Oct'
11='Nov'
12='Dec';
run;
data test;
format month mon3.;
input month amount;
cards;
9 1500
2 8200
3 3256
4 7412
5 2125
6 2536
;
run;
proc print;run;
Haikuo
Haikuo,
I coded that way because the OP requested:
"Is there any way to display month names instead of number in my above example(Except PROC FORMAT)???".
As your sister I strongly suggest you to edit your last post in https://communities.sas.com/message/135484#135484
My apology, I only read what I want to read.
And LOL, Thanks, Linlin, for your safty concern. as I am typing, I am hiding in a cave with my bullet-proof vest on, hopefully it is sufficient for now.
Haikuo
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.