Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6997637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:18:30+00:00 2026-05-27T20:18:30+00:00

I am having the following issue : I have a table which looks like

  • 0

I am having the following issue :

I have a table which looks like this :

WEIGHT    DATE  8/1/11    1/1/11   5/1/11 ... 10/25/11 
NAME   CLASS
NICK     1        A          .        A       .
JOHN     1       c+         C-        .        B-
JOHN     2        A          .        .        .
MIKE     2       B           B        B+        A
BOB      3       D           C        C         .
...

The dates are random dates, and they are not ordered .

I would like to order my dates (my columns) in sas. I looked up some things on google but there is nothing for this particular problem, since I have 300 dates, and therefore 300 columns names.

For you information :

My data originally looked like this :

calendar1 :

NAME CLASS CALENDaRDATE GPA
JOHN  1      1/1/11      C-
JOHN  1      8/1/11      C+
...

And I used this proc to create my table :

    proc sort data=calendar1;
        by  NAME ClASS CALENDARDATE;
    run;

    PROC TRANSPOSE DATA = calendar1 OUT = calendar2 ;
       BY nAME cLASS; 
       VAR GPA;
       ID CALeNdaRDATE; 
    RUN ; 

Do you have an Idea on how to sort my columns by dates ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:18:31+00:00Added an answer on May 27, 2026 at 8:18 pm

    This is a not-so-elegant solution for your reference (some are borrowed from CarolinaJay65’s input). You can reorder the column using RETAIN statement.

    I don’t think you can keep column name like ‘5/1/11’ since SAS doesn’t allow “/” in column name. Also the first character can’t be numerical.

    data work.calendar1 (drop=dt);
     input name $ class $ dt $ gpa $;
     calendardate=mdy(scan(dt,1),scan(dt,2),scan(dt,3)); 
      format calendardate mmddyy10.;
    datalines;
     JOHN  1      1/1/11      C-
     JOHN  1      8/1/11      C+
     JOHN  1      10/25/11    B-
     JOHN  2      8/1/11      A
     NICK  1      8/1/11      A
     NICK  1      5/1/11      A
     MIKE  2      8/1/11      B
     MIKE  2      1/1/11      B
     MIKE  2      5/1/11      B+
     MIKE  2      10/25/11    B
     BOB   3      10/25/11     D
     BOB   3      1/1/11      C
     BOB   3      5/1/11      C
     ;
    
    proc sort data=work.calendar1;
     by  NAME ClASS CALENDARDATE;
    run;
    
    PROC TRANSPOSE DATA = calendar1 OUT = calendar2(drop=_name_) ;
     BY nAME cLASS; 
     VAR GPA;
     ID CALeNdaRDATE; 
    RUN ; 
    
    proc sort data=calendar1(keep=CALENDARDATE) out=datecol nodupkey;
    by CALENDARDATE;
    run;
    
    data datecol;
    set datecol;
    format col $11.;
    col=cats('_',tranwrd(put(CALENDARDATE,mmddyy10.),'/','_'));
    run;
    
    proc sql;
    select col into :x separated by ' ' from datecol;
    quit;
    
    data calendar2;
    retain name class &x;
    set calendar2;
    run;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following application which replicates an issue I'm having in a larger
I am having trouble with the following SQL statement. I have had this issue
I am having following issue with reading binary file in C. I have read
I'm designing a mySQL DB and I'm having the following issue: Say I have
We are having an annoying issue with Firefox and cookies. We have the following
I'm having an issue with rails involving javascript. Basically, I have the following code:
I'm having the following issue: I have a tab-style app. Eacht tab has its
I have an issue with a table->setItem(index, 0, widg); statement having unwanted side-effects. I
I'm having an issue with MySQL . I have 2 Tables : Table A
I have the following code, which loops to get all images in a table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.