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?
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;
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;
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;
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.
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.