Ha ha. My instructions made you smell like 'Homework,' but it's not. Sorry if it felt like that. I posted a similar query before which I got answers but didn't get what I am trying to achieve so, I am trying it in a different way.
here is what I tried. My request is where the mean or n or sd values are missing. Do we have to just write 'IF' and 'ELSE' conditions to achieve as per my previous instructions?
if n =. then it displays as '0' in the same format as other numbers
if mean = . then id displays as the blank with the same format (length ) as other numbers and the same applies to sd. so that the string length remains the same.
data have;
input subjid n mean sd;
cards;
01 . . .
02 1 1.2 .
03 10 2.4 1.15
04 1 1.4 0.05
05 15 110.4 10.05
06 1 110.4 .
07 100 110.4 12.35
08 100 8.5 12.35
09 10 108.5 100.35
;
run;
data want;
length string1 $2500;
set have;
retain subjid n mean sd string1 string2;
string1= "n = "||put(n , 3.0)||" Total change in School in New York, Mean (SD): "||put(mean , 5.1)||" ("||put(sd , 6.2)||")";
string2= "n = "||put(n , 3.0)||" Total change in School in Maine, Mean (SD): "||put(mean , 5.1)||" ("||put(sd , 6.2)||")";
run;
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Result
n = 10 Total change in School in New York, Mean (SD): 2.4 ( 1.15)--->string1
n = 10 Total change in School in Maine, Mean (SD): 2.4 ( 1.15)--->string2
n = 100 Total change in School in New York, Mean (SD): 110.4 ( 12.35)--->string1
n = 100 Total change in School in Maine, Mean (SD): 110.4 ( 12.35)--->string2
n = . Total change in School in New York, Mean (SD): . ( . )
n = . Total change in School in Maine, Mean (SD): . ( . )
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
... View more