Hi every one,
I am going to loop over unique value of a date series (date1) to create a series of number for name of file in the form of map_0000`i'.png.
date1 one is a date of specific day of a month and distance between two dates in a row in 30 or 31.
this is my code
levelsof date1, local (fdate2)
foreach i of local fdate2{
local leg=string(`i', "%tdMonth,_CCYY")
local name=string((`i'-19436)/30)+1,"%05.0f")
grmap inflation, t(`i') legtitle("Monthly Inflation Rate %") fcolor(Blues2) clnumber(4) ocolor(Greys) clmethod(custom) clbreaks (0 10 15 20 25 30 35 40 60) polygon(data(iran_shp.dta) ocolor(gs8) osize(vvthin)) label(data("iran.dta") xcoord(_CX) ycoord(_CY) label(ADM1_FA) color(black) size(*1) length(50)) title("Provincial Monthly Rate of Inflation in Iran `leg'" )
graph export "map_`name'.png", as(png)
}
this line local name=string(((`i'-19436)/30)+1,"%05.0f") create filename. Unfortunately, it does not produce numbers in a row and there are breaks in some points. Note that difference between unique values are 30 or 31.
there are unique values which I loop over.
levelsof date1
19436 19466 19497 19528 19559 19590 19621 19652 19682 19712 19742 19772 19802 19831 19862 19893 19924 19955 19986 20017 20047 20077 20107 20137 20167 20196 20227 20258 20289 20320 20351 20382 20412 20442 20472 20502 20532 20561 20592 20623 20654 20685 20716 20747 20777 20807 20837 20867 20897 20927 20958 20989 21020 21051 21082 21113 21143 21173 21203 21233 21263 21292 21323 21354 21385 21416 21447 21478 21508 21538 21568 21598 21628 21657 21688 21719 21750 21781 21812 21843 21873 21903 21933 21963 21993 22022 22053 22084 22115 22146 22177 22208 22238 22268 22298 22328 22358 22388 22419 22450 22481 22512 22543 22574 22604 22634
I really appreciate your help a head of time.
0 Response to loop over unique values to create a sequence of consecutive numbers
Post a Comment