BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Zatere
Quartz | Level 8

Hello,

 

I have the following data:

data have;
input condition $ 1. _6  _5 _4 _3 _2 _1;
datalines;
A 14 14 8 0 0 0
B 3904 3918 3926 3926 3926 3926
C 910 917 917 917 918 922
D 1821 1816 1824 1825 1837 1824
E 5 2 2 2 3 3
F 1.8 1.8 1 0 0 0
;
run;

I then create dates formats:

 

DATA _NULL_;
CALL SYMPUT ('_6Day',PUT(today() - 6,DATE9.));
CALL SYMPUT ('_5Day',PUT(today() - 5,DATE9.));
CALL SYMPUT ('_4Day',PUT(today() - 4,DATE9.));
CALL SYMPUT ('_3Day',PUT(today() - 3,DATE9.));
CALL SYMPUT ('_2Day',PUT(today() - 2,DATE9.));
CALL SYMPUT ('_1Day',PUT(today() - 1,DATE9.));
RUN;

Then I create the report:

PROC REPORT DATA= have ; 
define _6 / display "&_6Day";
define _5 / display "&_5Day";
define _4 / display "&_4Day";
define _3 / display "&_3Day";
define _2 / display "&_2Day";
define _1 / display "&_1Day";
run;

have.JPG

However, when I change the dates formats then I don't get the desired output:

 

DATA _NULL_;
CALL SYMPUT ('_6Day',PUT(today() - 6,DDMMYY10.));
CALL SYMPUT ('_5Day',PUT(today() - 5,DDMMYY10.));
CALL SYMPUT ('_4Day',PUT(today() - 4,DDMMYY10.));
CALL SYMPUT ('_3Day',PUT(today() - 3,DDMMYY10.));
CALL SYMPUT ('_2Day',PUT(today() - 2,DDMMYY10.));
CALL SYMPUT ('_1Day',PUT(today() - 1,DDMMYY10.));
RUN;

PROC REPORT DATA= have ; 
define _6 / display "&_6Day";
define _5 / display "&_5Day";
define _4 / display "&_4Day";
define _3 / display "&_3Day";
define _2 / display "&_2Day";
define _1 / display "&_1Day";
run;

I get this:

have2.JPG

while I want to get the below:

 

Condition 30/12/2020 31/12/2020 01/01/2021 02/01/2021 03/01/2021 04/01/2021
A 14 14 8 0 0 0
B 3904 3918 3926 3926 3926 3926
C 910 917 917 917 918 922
D 1821 1816 1824 1825 1837 1824
E 5 2 2 2 3 3
F 1.8 1.8 1 0 0 0

 

It seems that the format DDMMYY10. changes how the report is displayed. Is there any way to fix it?

 

Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The default SPLIT character for PROC REPORT is a slash.  Just tell it to use some other character to mark where you want it to insert line breaks.

PROC REPORT DATA= have split='ff'x; 
define _6 / display "&_6Day";
define _5 / display "&_5Day";
define _4 / display "&_4Day";
define _3 / display "&_3Day";
define _2 / display "&_2Day";
define _1 / display "&_1Day";
run;

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Excel doesn't like the / character, it means line break in Excel. If you use a format with dashes or other separators, the problem goes away.

--
Paige Miller
Tom
Super User Tom
Super User

The default SPLIT character for PROC REPORT is a slash.  Just tell it to use some other character to mark where you want it to insert line breaks.

PROC REPORT DATA= have split='ff'x; 
define _6 / display "&_6Day";
define _5 / display "&_5Day";
define _4 / display "&_4Day";
define _3 / display "&_3Day";
define _2 / display "&_2Day";
define _1 / display "&_1Day";
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 648 views
  • 1 like
  • 3 in conversation