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

Inside my project, I'd like to create a summary table in which I represent for each indicator the score relating to a specific date.

The problem is that the correct data type for almost all indicators is PERCENTN9.2 while for one is 6.

 

In other words, my output should be

 

Indicator      Score

1                    12,86%

2                    110,96%

3                    4.853

4                    30,64%

 

Is it possible to obtain this output?

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

Hi

 

If it is for printed output, you can use Proc REPORT and the CALL DEFINE routine to achive this, see example below.

 

data have;
  input
    Indicator
    Score
;
cards;
1 0.1286
2 1.1096
3 4.853
4 0.3064
;

proc report data=have;
  column indicator score _dummy;
  define indicator / display;
  define score / display;
  define _dummy / computed noprint;

  compute _dummy;
    if indicator = 3 then do;
      call define("score", "format", "8.4");
    end;
    else do;
      call define("score", "format", "percentn9.2");
    end;
  endcomp;
run;

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes. What youwould do is create a character variable (remember character variables can hold anything) and then put each of your values into the correct format into there and print that (score_char in the below will contain the mismatched formats):

data want (keep=indicator score_char);
  set have;
  length score_char $200;
  score_char=ifc(indicator=3,put(score,5.3),put(score,percent5.));
run;
BrunoMueller
SAS Super FREQ

Hi

 

If it is for printed output, you can use Proc REPORT and the CALL DEFINE routine to achive this, see example below.

 

data have;
  input
    Indicator
    Score
;
cards;
1 0.1286
2 1.1096
3 4.853
4 0.3064
;

proc report data=have;
  column indicator score _dummy;
  define indicator / display;
  define score / display;
  define _dummy / computed noprint;

  compute _dummy;
    if indicator = 3 then do;
      call define("score", "format", "8.4");
    end;
    else do;
      call define("score", "format", "percentn9.2");
    end;
  endcomp;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1142 views
  • 0 likes
  • 3 in conversation