You do not specify RouterOS version, probably v7 because v6 do not have as-value for ping.
But on v7 as-value still no return stats, but only single pings (you can calc it sum all 3 times and divide by 3)...
Alternative for v6 (work also on v7)
:put ([/tool flood-ping [:resolve "www.mikrotik.com"] count=3 as-value]->"avg-rtt")
For v7
{
:local test [:ping [:resolve "www.mikrotik.com"] count=3 as-value]
:local avg 0
:foreach try in=$test do={:set avg ($avg + ($try->"time"))}
:set avg ($avg / [:len $test])
:put $avg
}
The first method provide more human readable values (50), the second not so easy:
00:00:00.050994
Trimming the string, can be extracted only the interested part:
{
:local test [:ping [:resolve "www.mikrotik.com"] count=3 as-value]
:local avg 0
:foreach try in=$test do={:set avg ($avg + ($try->"time"))}
:set avg ($avg / [:len $test])
:local out ""
:set out ( ([:tonum [:pick $avg 6 8]] * 1000000) + \
([:tonum [:pick $avg 10 12]] * 1000) + \
[:tonum [:pick $avg 12 15]] \
)
:put "$($out / 1000)ms"
}