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

Date Month Sort in VA

Reply
Contributor
Posts: 28

Date Month Sort in VA

I am performing data manipulation for VA and I have date valiable in date format.

I calculated month using SAS function in SAS-EG and I got numeric output (1,2,3...). I wanted to have month in Character form (Jan, Feb..etc). So, I used Proc format; value m ;

1='Jan'....;

run;

I am using this in a Line Graph and month is a category variable on X-axis, when I sort, I get the sorting in Alphabetical order Apr being the first

 

I tried little variation in proc format:

1='1:Jan' and when I sort I get this order 1, 11, 12, 2, 3, 4, 

 

Is there any way I can get month in Character form and when I sort I get the actual order in Visual Analytics.

 

Thanks

Respected Advisor
Posts: 4,645

Re: Date Month Sort in VA

You're very close with your final variation.  You could try adding a leading zero for months 1-9:

 

value m 1='01:Jan' ......;

 

Or you could use a leading blank:

 

value m 1=' 1:Jan' ......;

 

Again, the leading blank would be for months 1-9 only.

Super User
Posts: 1,208

Re: Date Month Sort in VA

Use your original date data item in SAS Visual Analytics and simply change the format in the data pane properties panel to a month format and you'll get the ascending month order you desire.

 

Kind Regards,

Michelle

Contributor
Posts: 28

Re: Date Month Sort in VA

Thanks. One more thing. Is there any way I can find teh Week number in VA. Instead of using a week function in EG?

Super User
Posts: 1,208

Re: Date Month Sort in VA

There is no week related format available within the Visual Analytics data item properties pane however you can create a calculated item and use the WeekNumber( ) operator on date data item that will return a week number (0-53) for the date.

 

If this has answered your question, please mark the question as solved.

 

Kind Regards,

Michelle

Post a Question
Discussion Stats
  • 4 replies
  • 374 views
  • 2 likes
  • 3 in conversation