Hi Logan,
Tried to make a function, but got stuck on append.
function void get_series_BSL(string dataname)
set echo off
set messages off
string bslurl = "
http://api.bls.gov/publicAPI/v1/timeseries/data/"~dataname
string s = readfile(bslurl)
sprintf q "\""
sprintf sq "\'"
sprintf nl "\n"
s = strsub(s,q,"")
s = strsub(s,"{year:",nl)
s = strsub(s," ","")
s = strsub(s,"[","")
s = strsub(s,"{","")
s = strsub(s,"]","")
s = strsub(s,"}","")
s = strsub(s,"'","")
s = strsub(s,":",",")
s = strsub(s,",period,","")
s = strsub(s,","," ")
s = strsub(s,"seriesID","obs blank blank blank ")
bundle dt
scalar i = 1
string line
scalar lcount = 0
loop while getline(s, line)
temp = strsplit(line,1)~","~strsplit(line,5)
if i > 2
sprintf ii "%d", i-2
dt.@ii = temp
temp = dt[@ii]
lcount ++
endif
i++
endloop
outfile test.csv --write
printf "%s\n", dt[1]
loop for (j = lcount; j>1; j--)
printf "%s\n", dt[$j]
endloop
outfile test.csv --close
delete dt
append test.csv #It fails here because is inside function
end function
set echo off
set messages off
clear
get_series_BSL("LAUCN040010000000005")