HI all,
I am using bellow code...everything is working perfectly except the actlevel variable..
Actlevel value truncating when Value is Total...it is displaying as "Tota"..
is there any way to avoid this truncation ??
Proc Report data=Sasuser.admit nowd out=qq;
Column Actlevel Sex Fee;
Define actlevel/Group format=$10.;
define sex/group;
define fee/analysis;
break after actlevel/summarize;
compute actlevel;
If _break_ = "ActLevel" then
Actlevel="Total";
endcomp;
run;
Make a NEW variable.
proc report data=sashelp.class nowd ;
column sex sex2 age ;
define sex/group noprint ;
define sex2/group computed width=5 ;
define age/analysis;
break after sex/summarize;
compute sex2 / character length=5 ;
sex2=sex;
if lowcase(_break_) = "sex" then sex2="total";
endcomp;
run;
Hi Rajesh,
The truncation happens because in the original dataset the lenght of actlevel variable is only $4. the format won't increase the length. The length of value 'Total' is 5 so the value will be truncated when trying to store that value to actlevel variable only with length 4.
I just created another dataset just to set the value of ActLevel as $10. and used that data set as input to proc report... now the trnuncation issue resolved.
data admit;
length ActLevel $10;
set Sasuser.admit;
run;
Proc Report data=admit nowd out=qq;
Column Actlevel Sex Fee;
Define actlevel/Group format=$10.;
define sex/group;
define fee/analysis;
break after actlevel/summarize;
compute actlevel;
If _break_ = "ActLevel" then
Actlevel="Total";
endcomp;
run;
Most likely the variable ACTLEVEL is length $4.
For example try this program.
proc report data=sashelp.class nowd ;
column sex age ;
define sex/group format=$10.;
define age/analysis;
break after sex/summarize;
compute sex;
if lowcase(_break_) = "sex" then sex="total";
endcomp;
run;
Yes,,,the value truncating just because of length of the variable.In Admit dataset length of the actlevel variable is 4.That is the reason only "Tota" is displaying.
so is there any way to increase the Actlevel variable length with in the Proc report instead of writing another datastep ??
Thanks,
Make a NEW variable.
proc report data=sashelp.class nowd ;
column sex sex2 age ;
define sex/group noprint ;
define sex2/group computed width=5 ;
define age/analysis;
break after sex/summarize;
compute sex2 / character length=5 ;
sex2=sex;
if lowcase(_break_) = "sex" then sex2="total";
endcomp;
run;
Ahhh i see..
Thanks Tom..
But why don't SAS allow us to update the variable length with in the Procedure..I thought some options available in proc report like how we apply Format to particular variable.
Any how ,its working fine for me.
Thanks Again,
You can apply formats, but formats do not change the definition of the variable, just how they are displayed.
Okie,,Got it,,
Thanks Tom for your valuable time..
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!
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.