BookmarkSubscribeRSS Feed
tekish
Quartz | Level 8

Dear expert.

I am trying to transpose the date values into column headers.

here is sample data.

data have;
input state $ regid date:MMDDYY10.;
datalines;
DC 456789 2/1/2021
DC 450231 2/1/2021
DC 450556 2/2/2021
DC 453246 2/3/2021
DC 458237 2/4/2021
VA 567894 2/8/2021
VA 560233 2/10/2021
VA 560654 2/11/2021
VA 563642 2/11/2021
VA 568732 2/11/2021
CA 678945 2/15/2021
CA 670231 2/15/2021
CA 670556 2/18/2021
CA 673246 2/18/2021
CA 678237 2/18/2021
NM 178945 2/22/2021
NM 170231 2/22/2021
NM 170556 2/26/2021
NM 173246 2/26/2021
NM 178237 2/26/2021
run;

 sample output template:

 Wk1WKL2WK3WK4
State2/1/20212/2/20212/3/20212/4/20212/5/20212/8/20212/9/20212/10/20212/11/20212/12/20212/15/20212/16/20212/17/20212/18/20212/19/20212/22/20212/23/20212/24/20212/25/20212/26/2021
DC456789450556453246458237                
DC450231                   
VA    567894  560233560654           
VA        563642           
CA          678945  670556      
CA          670231  678237      
NM               178945   170556

 

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

Column WK1 is either a date or not, and either uses a date format or not.

 

 

Tom
Super User Tom
Super User

That looks like a REPORT and not a dataset. So use PROC REPORT.

proc report data=have;
  column state regid,date;
  define state/ group order=data;
  define date / across 'week';
  define regid / ' ';
run;

image.png

tekish
Quartz | Level 8

Hi Tom,

Thanks for your quick reply. you right it is a REPORT. How Do I Change the header for the Date column values?

week1:02/01/2021 until 02/05/2021

week2:02/08/2021 until 02/12/2021

week3:02/15/2021 until 02/19/2021

week4:02/22/2021 until 02/26/2021

                      Week1

02/01/2021

02/02/2021

02/03/2021

02/04/2021

02/05/2021

 

 

 

 

 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 795 views
  • 4 likes
  • 3 in conversation