BookmarkSubscribeRSS Feed
DartRodrigo
Lapis Lazuli | Level 10

Hi guys, Today i need to find a way to format the length of the cells in proc report. That's my code:  

 

%GLOBAL ACTUAL_MONTH NUM VAR COLUNA;

DATA EXTRACT;
    LENGTH 	ACTIVITY	$60 F0	3 F1	3 F2	3 F3	3 F4	3 F5	3 F6	3
			F7	3 F8	3 F9	3 F10	3 F11	3 F12	3 F13	3 F14	3
			F15	3 F16	3 F17	3 F18	3 F19	3 F20	3 F21	3 F22	3
			F23	3 F24	3 F25	3 F26	3 F27	3 F28	3 F29	3 F30	3 F31	3;
	INFILE "/home/re43526/quickview/SCHEDULER.txt" DLM=";" TRUNCOVER
        DSD ;
	INPUT 	ACTIVITY F0 F1	F2	F3	F4	F5	F6	F7	F8	F9	
			F10	F11	F12	F13	F14	F15	F16	F17	F18	
			F19	F20	F21	F22	F23	F24	F25	F26	F27	
			F28	F29	F30 F31;			

%MACRO SCHEDULE(NUM);

%LET ACTUAL_MONTH = %SYSFUNC(DATE(),MONNAME.);
%PUT &ACTUAL_MONTH.;

DATA SCHEDULE;
%DO I = 0 %TO &NUM.;
%LET VAR = %QTRIM(%TRIM(%SYSFUNC(PUTN(%SYSFUNC(INTNX(DAY,%SYSFUNC(DATE()),+&&i)),DATE9.))));
%PUT &VAR.;
%LET MNAME = %SUBSTR(&VAR.,3,3);
%LET DNAME = %SUBSTR(&VAR.,1,2);
   LENGTH ACTIVITY $ 60;
	SET EXTRACT(RENAME=F&&I=%CMPRES(&&MNAME._&&DNAME.));
%END;
DROP F:;
RUN;

PROC SQL;
CREATE TABLE VARS AS
SELECT VARNUM, NAME
FROM DICTIONARY.COLUMNS
WHERE MEMNAME = "SCHEDULE";
QUIT;

PROC SQL NOPRINT;
SELECT NAME INTO: COLS SEPARATED BY "	"
FROM VARS
QUIT;
%PUT &COLS.;

PROC REPORT DATA=SCHEDULE
	STYLE(REPORT) =  [BORDERWIDTH=20 BORDERCOLOR=WHITE]
	STYLE(COLUMN) =  [BACKGROUNDCOLOR=WHITE BORDERWIDTH=2 BORDERCOLOR=WHITE CELLWIDTH=40%]
	STYLE(LINES ) =  [BACKGROUNDCOLOR=WHITE BORDERCOLOR=WHITE];
	COLUMN &COLS.;
%DO I = 0 %TO &NUM.;
%LET VAR = %QTRIM(%TRIM(%SYSFUNC(PUTN(%SYSFUNC(INTNX(DAY,%SYSFUNC(DATE()),+&&i)),DATE9.))));
%PUT &VAR.;
%LET MNAME = %SUBSTR(&VAR.,3,3);
%LET DNAME = %SUBSTR(&VAR.,1,2);
	DEFINE ACTIVITY / DISPLAY STYLE(COLUMN)=[BACKGROUNDCOLOR=#F8F8F8 WIDTH=10in];
	DEFINE &&MNAME._&&DNAME. / DISPLAY STYLE(COLUMN)=[WIDTH=10%];
	DEFINE ACTIVITY / ORDER;
   	COMPUTE &&MNAME._&&DNAME.;
		IF &&MNAME._&&DNAME. = 1      THEN 
				CALL DEFINE(_col_,"style","style={background=lightGREEN  COLOR=lightGREEN }");
		IF &&MNAME._&&DNAME. = 2      THEN 
				CALL DEFINE(_col_,"style","style={background=YELLOW COLOR=YELLOW}");
		IF &&MNAME._&&DNAME. IN (0,.) THEN 
				CALL DEFINE(_col_,"style","style={background=WHITE       COLOR=WHITE}");
	ENDCOMP;
	TITLE BLANK=YES;
%END;
RUN;
%MEND;

%SCHEDULE(15);

It is inside a macro step and it runs very well, but the width statement it is not working. how can i specify the width of the columns i want ? Thanks

7 REPLIES 7
DartRodrigo
Lapis Lazuli | Level 10
Sorry guys, i'm using IE because in chrome it get the 404 error everytime i try to sign in.
DartRodrigo
Lapis Lazuli | Level 10
My code it is in the attached file.
BrunoMueller
SAS Super FREQ

To see SAS code that gets generated by your macro I suggest you switch MPRINT option on using

 

options mprint;

Since you have 15 days and each day column should have 10% of the overall width, there will be not be enough space.

 

I would start with a simple example and try out the width settings and see how they interact, also the type of ODS destination might matter.

 

Please change the title of your post, as there is nothing with Proc FORMAT in your code.

 

Bruno

 

 

ballardw
Super User

Also post code, especially long blocks in the code section. You open that by using the the little SAS "Run" icon on the forum text menu at the top of your post.

DartRodrigo
Lapis Lazuli | Level 10

Sorry about the horrible code in text box. Like i said i was using IE and some features didn't appear yesterday.

And i'm using Proc Report

Reeza
Super User
To use Chrome, go to SAS.com, log out, log back in and then navigate back to communities.sas. The little work is worth it over using IE in my opinion!
DartRodrigo
Lapis Lazuli | Level 10

Changed and insert the code.

 

Thanks

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 1906 views
  • 0 likes
  • 4 in conversation