Hi Everyone,
I am creating a report via proc report and have lines being used as separators at specific rows, however the text is being cut off after 36 characters for some reason and I'm not sure why. Report code is below, if anyone can give me some insight as to why this is happening please let me know! The text being cut off is in the last "compute before" block.
proc report data = test_table headline;
title 'Return of Results for SVA0901023';
columns NAME Rater_N Rater_Mean Rater_STD Rater_MIN Rater_MAX Rater_range Scholar_MEAN Difference ROW;
define NAME / display 'Name' width = 10 format = $teamscience.;
define Rater_N / display 'Rater N' width = 2;
define Rater_Mean / analysis 'Rater Mean' format=8.1;
define Rater_STD / analysis 'Std Dev' format=8.1;
define Rater_MIN / analysis 'Rater Min' format = 8.1 noprint;
define Rater_MAX / analysis 'Rater Max' format = 8.1 noprint;
define Rater_range / computed 'Rater Range' format=8.1;
define Scholar_MEAN / analysis 'Scholar Rating' width = 10;
define Difference / computed 'Difference' format=8.1;
define row / order noprint ;
compute Rater_range;
Rater_range = sum(Rater_MIN.sum,-1*Rater_MAX.sum);
endcomp;
compute Difference;
Difference = sum(Rater_MEAN.sum,-1*Scholar_MEAN.sum);
if Rater_MEAN.sum = . or Scholar_MEAN.sum = . then Difference = .;
endcomp;
compute before ROW / style={just=left fontweight=bold fontsize=3} ;
len=55;
if row=1 then text='Foundational leadership competencies';
else if row=10 then text='Professionalism';
else if row=15 then text='Team Building and Team Sustainability';
else if row=27 then text='Appropriate Use of Resources and Execution of Study';
else len=0;
line text $varying. len;
endcomp;
run;
If you look, or count, very closely you will note that the very first value you use for TEXT= of
Foundational leadership competencies
is exactly 36 characters long.
So that has set the length of the variable "text".
I suspect that if you use:
if row=27 then text='Appropriate Use of Resources and Execution of Study'; else if row=1 then text='Foundational leadership competencies'; else if row=10 then text='Professionalism'; else if row=15 then text='Team Building and Team Sustainability'; else len=0;
where the longest value appears first the issue goes away.
This is the same behavior that a data step has for new variables where an explicit length statement does not provide a length before use.
Or try
Length text $ 60; before the if/then/else block.
@Cynthia_sas can you help?
Compute before a;
length Text $50;
if Line = 1 then text = "This Car is Asian";
else if Line = 2 then Text = "This Car is European ";
else If Line = 3 then Text = "I Love this car but I cannot afford it"; else text = "If Oprah was here, each of us would get one";
Line @1 Text $50.;
endcomp;
Can you try this? But I guess put $ 55 if that's how long you have in your OP.
If you look, or count, very closely you will note that the very first value you use for TEXT= of
Foundational leadership competencies
is exactly 36 characters long.
So that has set the length of the variable "text".
I suspect that if you use:
if row=27 then text='Appropriate Use of Resources and Execution of Study'; else if row=1 then text='Foundational leadership competencies'; else if row=10 then text='Professionalism'; else if row=15 then text='Team Building and Team Sustainability'; else len=0;
where the longest value appears first the issue goes away.
This is the same behavior that a data step has for new variables where an explicit length statement does not provide a length before use.
Or try
Length text $ 60; before the if/then/else block.
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.