I am trying to do a print a table but the superscript will not work for one of the variables
option missing='0' nodate nonumber orientation=landscape ;
ods escapechar="~";
data ALL;
set ALL;
length outcome $61.
if variablenames eq 'stall' then outcome='The Number of Reported Cases (%)';
if variablenames eq 'caseassign_per' then outcome='The Number of Cases Assigned for an Investigation (%)';
if variablenames eq 'passigned_per' then outcome='Partners assigned (%)';
if variablenames eq 'test_30_per' then outcome='Testing Among OPs (%)';
if variablenames eq 'NONMISSING_REFERAL_active' then outcome='The Number of Cases Active Referral (%)';
if variablenames eq 'NONMISSING_REFERAL_passive' then outcome='The Number of Cases Passive Referral (%)';
if variablenames eq 'part_HIV_test_per' then outcome='The Number of Partners Tested for HIV (%)';
if variablenames eq 'NONMISSING_Active_REFPart' then outcome= 'The Number of Partners Active Referral (%)';
if variablenames eq 'NONMISSING_passive_REFPart' then outcome='The Number of Partners Passive Referral (%)';
***;
if variablenames eq 'stdall' then count=1;
if variablenames eq 'caseassign_per' then count=2;
if variablenames eq 'passigned_per' then count=3;
if variablenames eq 'test_30_per' then count=4;
if variablenames eq 'NONMISSING_REFERAL_active' then count=5;
if variablenames eq 'NONMISSING_REFERAL_passive' then count=6;
if variablenames eq 'part_test_per' then count=7;
if variablenames eq 'NONMISSING_Active_REFPart' then count=8;
if variablenames eq 'NONMISSING_passive_REFPart' then count=9;
if outcome='The Number of Cases Assigned for an Investigation (%)' then outcome=catx(' ',outcome,'~{super 2}');
if outcome='Testing Among OPs (%)' then outcome=catx(' ',outcome,'~{super 3}');
if outcome='The Number of Cases Active Referral (%)' then outcome=catx(' ',outcome,'~{super 4}');
if outcome='The Number of Cases Passive Referral %)' then outcome=catx(' ',outcome,'~{super 4}');
if outcome='Partners assigned (%)' then outcome=catx(' ',outcome,'~{super 5}');
if outcome='Partners assigned (%)' then outcome=catx(' ',outcome,'~{super 5}');
if outcome='The Number of Partners Tested(%)' then outcome=catx(' ',outcome,'~{super 3}');
if outcome='The Number of Partners Passive Referral (%)' then outcome=catx(' ',outcome,'~{super 4}');
if outcome='The Number of Partners Active Referral (%)' then outcome=catx(' ',outcome,'~{super 4}');
run;
PROC SORT DATA=ALL2;
BY descending pop diagnosis COUNT;
RUN;
proc print data= ALL2 noobs; run;
Instead of this
I get this
Well, that sure looks like it should work. Maybe it's a SAS bug. I'm not sure.
You could try changing this
if outcome='The Number of Partners Passive Referral (%)' then outcome=catx(' ',outcome,'~{super 4}');
to the below just to see if we can find a work-around
if outcome='The Number of Partners Passive Referral (%)' then outcome=cat(outcome,' ','~{super 4}',' ');
I'm just changing from CATX to CAT and padding a space on the end. It's basically just a shot in the dark.
Jim
Well, that sure looks like it should work. Maybe it's a SAS bug. I'm not sure.
You could try changing this
if outcome='The Number of Partners Passive Referral (%)' then outcome=catx(' ',outcome,'~{super 4}');
to the below just to see if we can find a work-around
if outcome='The Number of Partners Passive Referral (%)' then outcome=cat(outcome,' ','~{super 4}',' ');
I'm just changing from CATX to CAT and padding a space on the end. It's basically just a shot in the dark.
Jim
You are not defining your variable long enough for the strings you trying to store in it.
332 data test; 333 length outcome $100; 334 outcome='The Number of Cases Assigned for an Investigation (%)' ; 335 outcome=catx(' ',outcome,'~{super 2}'); 336 len=length(outcome); 337 put (_all_) (=/); 338 339 340 run; outcome=The Number of Cases Assigned for an Investigation (%) ~{super 2} len=64
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.