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:
Wk1 | WKL2 | WK3 | WK4 | |||||||||||||||||
State | 2/1/2021 | 2/2/2021 | 2/3/2021 | 2/4/2021 | 2/5/2021 | 2/8/2021 | 2/9/2021 | 2/10/2021 | 2/11/2021 | 2/12/2021 | 2/15/2021 | 2/16/2021 | 2/17/2021 | 2/18/2021 | 2/19/2021 | 2/22/2021 | 2/23/2021 | 2/24/2021 | 2/25/2021 | 2/26/2021 |
DC | 456789 | 450556 | 453246 | 458237 | ||||||||||||||||
DC | 450231 | |||||||||||||||||||
VA | 567894 | 560233 | 560654 | |||||||||||||||||
VA | 563642 | |||||||||||||||||||
CA | 678945 | 670556 | ||||||||||||||||||
CA | 670231 | 678237 | ||||||||||||||||||
NM | 178945 | 170556 |
Column WK1 is either a date or not, and either uses a date format or not.
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;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.