I need help in my code.
a values =100 and 12
I need to have values like this (100%)
( 12%)
I am using the code cat("(",right(a),")").
I am getting values (100.0) and ( 12.0)
Please help
Is it a number or character?
new_var= catt("(", put(old_var/100, percent8.1), ")");
One possibility:
newvar = '(' || put(a, 3.) || '%)';
See if that's what you need.
Thank you for help.
This code help me. newvar = '(' || put(a, 3.) || '%)';
If you have an answer please mark the question answered 🙂
The code newvar = '(' || put(a, 3.) || '%)'; works for me as long as 'a' values are not zero.
for example when a=17, I am getting 17 ( 28%) what i need.
In some observation there are values i need to concatenate zero number also.
for example when a=0, I need values 0 ( 0%). But iam getting 0 ( %). Please help.
Thank you.
Is the variable you're using missing in that circumstance or is it 0?
I'm going to guess it's missing. You can use the COALESCE() function to assign the value 0 when the variable is missing.
newvar = '(' || put(coalesce(a, 0), 3.) || '%)';
The variable is zero. Thank you
Just the fact that you could possibly get 17 ( 28%) means that your program is a little different than what I imagine it to be. Show us exactly what is in your program (just the one or two relevant lines of code), and what the data values are to generate the wrong result.
If it was 0, it should work. Make sure you have no formats applied to the data that's causing 0 to appear as missing.
data have;
x=0;
y="("||put(x, 3.)||"%)";
run;
proc print; run;
Output:
Obs x y
1 0 ( 0%)
Hi I have another questions.
I need to produce a report like this: File attached
I am using the code: The output doesnot look same. Please help
OPTIONS nodate nonumber;
ods listing close;
ods escapechar="^";
title1 justify=right 'page ^{pageof}';
title2 "Table 14.3.1.1 Treatment-Emergent Adverse Event Frequency by Treatment -";
title3 "Number of Subjects Reporting the Event (% of Subjects Dosed) (Safety Population)";
footnote1 "Note: Adverse events (AEs) were coded with MedDRA Version 18.0.";
footnote2 "Program: /CA17139/sas_prg/stsas/tab/adam_tblae1a_auto.sas 16DEC2015 12:16";
footnote2 " %sysget(sas_execfilepath) &sysdate. &systime.";
options orientation=landscape formchar="|----|+|---+=|-/\<>*";
ods rtf file="C:\Users\vvemireddy\Desktop\ae_1.rtf" style=journal;
proc report data=four nowd headline headskip style(report)=[frame=void];
column grp aebodsys aedecod aetext cnt_pct4 ("JPZ" "_______________" cnt_pct1 cnt_pct2) cnt_pct3 cnt_pct5;
define grp/order noprint;
define aebodsys/order noprint;
define aedecod/display center noprint;
define aetext/ display 'Adverse Event' style(column)={asis=on cellspacing=.25pt just=left};
define cnt_pct1 / "300 mg" style(column)={cellspacing=.25pt just=left};
define cnt_pct2/ "900 mg" style(column)={cellspacing=.25pt just=left} ;
define cnt_pct3/ "400 mg Moxifloxacin" style(column)={cellspacing=.25pt just=left};
define cnt_pct4/"Plcebo" style(column)={cellspacing=.25pt just=left} ;
define cnt_pct5/"TOTAL" style(column)={cellspacing=.25pt just=left} ;
compute after grp/style={protectspecialchars=off};
n+1;
len=ifn(n=1,20,0);
dummy='\brdrt\brdrs';
line dummy $varying20. len;
endcomp;
run;
ods rtf close;
If this question is answered please mark this one answered and create a new question.
Also without data we have no idea what your resulting report actually looks like.
Please describe how it doesn't look right.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.