BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ayooo1
Obsidian | Level 7

How can I insert a blank row above the original row shown in the picture? Also how I can add indentation to 'Male' and 'Female'?

data EXDM;
retain SEX _7_ug_kg_day _9_ug_kg_day _12_ug_kg_day Total;
set EXDM;
keep SEX _7_ug_kg_day _9_ug_kg_day _12_ug_kg_day Total;
by descending SEX;
if _9_ug_kg_day=" " then _9_ug_kg_day="0";
run;
proc sort data=EXDM;
by descending SEX;
run;
proc report data=EXDM nowd;
title 'Demographics Characteristics';
title2 'All Patients Dosed';
columns ('Characteristics' SEX _7_ug_kg_day _9_ug_kg_day _12_ug_kg_day Total);
define SEX/'SEX';
define _7_ug_kg_day/'7ug/kg/day';
define _9_ug_kg_day/'9ug/kg/day';
define _12_ug_kg_day/'12ug/kg/day';
run;

Ayooo1_0-1671283498340.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Your SAS log contains PROC REPORT syntax errors and is also suggesting the correction. The "STYLE(header/column) =" option requires either curly or square brackets after the equals sign. I've corrected it here:

options orientation=LANDSCAPE;
ods pdf file='C:\Users\tonyw\Documents\saspdf.pdf';
proc report data=EXDM nowd
	style(header)={vjust=b};
title 'Demographics Characteristics';
title2 'All Patients Dosed';
columns ('Characteristics' SEX _7_ug_kg_day _9_ug_kg_day _12_ug_kg_day Total);
define SEX/'SEX'
	style(column)={indent=.25in};
define _7_ug_kg_day/'7ug/kg/day';
define _9_ug_kg_day/'9ug/kg/day';
define _12_ug_kg_day/'12ug/kg/day';
compute before;
line ' ';
endcomp;
run;
ods pdf close;

 

View solution in original post

12 REPLIES 12
sbxkoenk
SAS Super FREQ

Hello,

 

For the blank row , ... should be easy in PROC REPORT but I do not know off-hand (from the top of my head).

For the indentation, see here :

Koen

 
Cynthia_sas
SAS Super FREQ

Hi:

  It's not entirely clear to me where the blank line is needed or why. But the LINE statement is capable of adding blank lines. There are a few examples shown below, along with INDENT=.

Cynthia_sas_0-1671293422656.png

 

  Just keep in mind that INDENT= may not be respected by all destinations, since the OP didn't specify a destination, I'm showing the default HTML output here.

  Note that the LINE statement is exactly the same in all 3 examples. What is different is the location listed in the COMPUTE block. Also, in order to insert a blank line after every value of the SEX variable, it had to have the usage changed from the default of DISPLAY to ORDER. Also, added VJUST=B to make the headers for SEX and TOTAL look better.

Cynthia

Ayooo1
Obsidian | Level 7

when it run option 2, it comes back with error. It seems the error is from the define SEX part.

Ayooo1_0-1671313447584.png

 

PaigeMiller
Diamond | Level 26

Hello, @Ayooo1 

 

When you get an error in the log, we need to see the ENTIRE log for this PROC or DATA step, every single line in the log for this PROC or DATA step. Do not show us partial logs.

 

Please copy the log as text as paste it into the window that appears when you click on the </> icon.

PaigeMiller_0-1663012019648.png

--
Paige Miller
tarheel13
Rhodochrosite | Level 12

Did you put sex on the define statement? that might be why. show your full code please.

Cynthia_sas
SAS Super FREQ

Hi:
Please look at my examples carefully. Example 2 just has a COMPUTE BEFORE without any other location, which will put the blank line between the header and the first data row. Example 3 has a blank line after every value for the SEX variable. To use COMPUTE BEFORE SEX, as you show, the DEFINE statement for SEX but have a usage of ORDER or GROUP. Look at my #2 compared to my #3. It doesn't help if you show only a partial log. First, the errors are not highlighted in the snippet you show and second, without seeing ALL of the code, it is impossible to compare it to my example and see whether you actually followed #3 or made up your own combination of #2 and #3.
Cynthia

Ayooo1
Obsidian | Level 7

this is my entire log in the attachment below.

 

Ayooo1
Obsidian | Level 7

This is my entire code.

options nodate;
proc sort; by SUJID EXDSTXT; 
data Ex;
set Sasfile.EX;
keep SUBJID EXDSTXT;
by SUBJID EXDSTXT;
if first.SUBJID;
output;
EXDSTXT='Total';output;
run;
proc sort data=EX;
by SUBJID;
run;
data Dm;
retain SUBJID SEX;
set Sasfile.Dm;
if SEX="M" then SEX="Male";else SEX="Female";
keep SUBJID SEX;
run;
proc sort data=Dm;
by SUBJID;
run;
data Listing2;
merge Ex(in=a) Dm(in=b);
by SUBJID;
if a and b;
run;
proc sort data=Listing2;
by EXDSTXT;
run;
proc freq data=Listing2 noprint;
tables SEX*EXDSTXT / nopercent out=FreqST;
by EXDSTXT;
run;
proc sort data=FreqST;
by EXDSTXT;
run;
proc freq data=Listing2 noprint;
tables EXDSTXT/ nopercent out=FreqT (rename=(COUNT=Total));
by EXDSTXT;
run;
proc sort data=FreqT;
by EXDSTXT;
run;
data Listing2_1;
merge FreqT(in=a) FreqST(in=b);
by EXDSTXT;
if a and b;
run;
data Merged_CP (keep= DoseC_P EXDSTXT SEX);
set listing2_1;
by EXDSTXT;
retain COUNT PERCENT EXDSTXT SEX;
length DoseC_P $20;
DoseC_P= strip(put(COUNT,comma12.)||''|| put(-PERCENT/100,percent7.1));
run;
proc sort data=Merged_CP;
by descending SEX;
run;
proc transpose data=Merged_CP out=EXDM (drop=_NAME_);
by descending SEX ;
id EXDSTXT;
var DoseC_P;
run;
data EXDM;
retain SEX _7_ug_kg_day _9_ug_kg_day _12_ug_kg_day Total;
set EXDM;
keep SEX _7_ug_kg_day _9_ug_kg_day _12_ug_kg_day Total;
by descending SEX;
if _9_ug_kg_day=" " then _9_ug_kg_day="0";
run;
proc sort data=EXDM;
by descending SEX;
run;
options orientation=LANDSCAPE;
ods pdf file='C:\Users\tonyw\Documents\saspdf.pdf';
proc report data=EXDM nowd
	style(header)=(vjust=b);
title 'Demographics Characteristics';
title2 'All Patients Dosed';
columns ('Characteristics' SEX _7_ug_kg_day _9_ug_kg_day _12_ug_kg_day Total);
define SEX/'SEX'
	style(column)=(indent=.25in);
define _7_ug_kg_day/'7ug/kg/day';
define _9_ug_kg_day/'9ug/kg/day';
define _12_ug_kg_day/'12ug/kg/day';
compute before;
line ' ';
endcomp;
run;
ods pdf close;
SASKiwi
PROC Star

Your SAS log contains PROC REPORT syntax errors and is also suggesting the correction. The "STYLE(header/column) =" option requires either curly or square brackets after the equals sign. I've corrected it here:

options orientation=LANDSCAPE;
ods pdf file='C:\Users\tonyw\Documents\saspdf.pdf';
proc report data=EXDM nowd
	style(header)={vjust=b};
title 'Demographics Characteristics';
title2 'All Patients Dosed';
columns ('Characteristics' SEX _7_ug_kg_day _9_ug_kg_day _12_ug_kg_day Total);
define SEX/'SEX'
	style(column)={indent=.25in};
define _7_ug_kg_day/'7ug/kg/day';
define _9_ug_kg_day/'9ug/kg/day';
define _12_ug_kg_day/'12ug/kg/day';
compute before;
line ' ';
endcomp;
run;
ods pdf close;

 

Ayooo1
Obsidian | Level 7

Thank you that helped a lot.

Ayooo1
Obsidian | Level 7

say I just wanted to indent male and female instead of SEX, how can I do that?

PaigeMiller
Diamond | Level 26

@Ayooo1 wrote:

this is my entire log in the attachment below.

 


Please READ CAREFULLY. The request was the ENTIRE log for this PROC (in this case, PROC REPORT). Not the PROCs or DATA steps before this PROC.

 

Now, in the log under line 78, the error is explained clearly.

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 12 replies
  • 2665 views
  • 7 likes
  • 6 in conversation