Hello,

I am using FRED data to create a pdf report of unemployment information. The goal is to have the pdf state "The current rate is X, which is more/less/the same as last year's average rate of Y." However, Y is printed with multiple decimal points even when I try using the round() function.


To create the rounded variable:

gen year = substr(date, 1, 4)
gen ryear = real(year)
egen yrave = sum((UNRATE)/12), by(ryear)
gen yrave_r = round(yrave, 0.1)

After doing that, when asking Stata to list yrave_r or using codebook and describe, it would seem that the values of yrave_r are rounded to the .1 decimal place. However, then I try printing the number in a pdf:

putpdf begin
putpdf paragraph
putpdf text (yrave_r[1])

and instead of producing the nice rounded number reported with list, the pdf will include many more decimal points beyond the tenths place (for example 3.9000001 instead of just 3.9). Can someone explain to me why this is and how I can fix it?