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

 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 

bobeng_0-1621966513608.png

 

I get this 

bobeng_1-1621966549551.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jimbarbour
Meteorite | Level 14

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

View solution in original post

3 REPLIES 3
jimbarbour
Meteorite | Level 14

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

bobeng
Obsidian | Level 7
yes, it worked! thank you!
Tom
Super User Tom
Super User

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 3 replies
  • 615 views
  • 1 like
  • 3 in conversation