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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 685 views
  • 0 likes
  • 3 in conversation