BookmarkSubscribeRSS Feed
Brandon16
Obsidian | Level 7
Hi,

I have created a tabulate below but I need to sort the dates from earliest to latest.

Proc tabulate data J_final;
Class date;
Var move can;
Table (date=""),
(Move="")
(Can="");
Run;

My output would go in alphabetical order
Date move can
April16 4 6
April17 2 3
Aug16 6 4
Aug17 2 5
Etc

Any idea what i need to add to change it please?

1 REPLY 1
ballardw
Super User

I have to ask because it is a frequent problem with "dates". Is your date value an actual SAS date valued variable? This means that when you run proc contents on the data set or examine the variable properties the variable is Numeric and (usually) has a date format such as DATE9. , mmddyy10 or similar assigned.

 

If so then you assign a format that would have the month first such as WORDDATE and on the class statement for date use the order option formatted:

 

class date / order=formatted;

format date worddate18. ;

 

Provide data if that doesn't work. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

Unless you have removed a lot of stuff from your code the () in the table statement you show aren't doing much of anything

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1497 views
  • 0 likes
  • 2 in conversation