<html><head></head><body><div class="ydpe2c28b33yahoo-style-wrap" style="font-family: bookman old style, new york, times, serif; font-size: 16px;"><div dir="ltr" data-setdir="false" style=""><font style="" face="Helvetica Neue, Helvetica, Arial, sans-serif" size="3">Boa tarde a todos!!! Novamente agradecido pela ajuda anterior, e já pedindo desculpas por nova perturbação, mas de novo apareceu uma situação que não sei resolver. Segue o código R parecido com o outro para baixar dados via URL, onde agora x1 representa o código de modulo de um serviço, x2 o ano e x3 o código da rodada trimestral de realização desse serviço:</font></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;"><span style="color: rgb(128, 128, 128); font-size: x-small;">baixa_bancos<-function(x1,x2,x3){</span><br></div><div dir="ltr" data-setdir="false" style="font-size: 16px;"><div style=""><div style="font-family: bookman old style, new york, times, serif;"><font color="#808080" size="1">dados<-read.csv2(paste('http://.../arquivo_m", x1 ,"_a",x2,"_s", x3,".csv'",sep=""),</font><span style="color: rgb(128, 128, 128); font-size: x-small;">header=T, sep="|", dec =".", encoding = "UTF-8")</span></div><div style="font-family: bookman old style, new york, times, serif;"><font color="#808080" size="1">} </font></div><div style="font-family: bookman old style, new york, times, serif; font-size: 16px;"><br></div><div style="font-size: 16px;"><font face="Helvetica Neue, Helvetica, Arial, sans-serif">A chamada da macro fica algo assim:</font><br></div><div style="font-family: bookman old style, new york, times, serif; font-size: 16px;" dir="ltr" data-setdir="false"><span style="color: rgb(128, 128, 128); font-size: x-small;">a<- <span><span style="color: rgb(128, 128, 128); font-family: bookman old style, new york, times, serif; font-size: x-small;">vetor de código de módulos</span></span>; b<-<span><span style="color: rgb(128, 128, 128); font-family: bookman old style, new york, times, serif; font-size: x-small;">vetor de anos</span></span>; </span><font color="#cd232c"><span style="font-size: x-small;">c</span><span style="font-size: x-small;"><-</span><b style="font-size: x-small;">????</b></font><br></div><div style="font-family: bookman old style, new york, times, serif;"><font size="1" color="#808080">for(i in 1:length(a)); </font><span style="color: rgb(128, 128, 128); font-size: x-small;">for(j in 1:length(b)); </span><span style="color: rgb(128, 128, 128); font-size: x-small;">for(k in 1:length(c))</span></div><div style="font-family: bookman old style, new york, times, serif;"><font size="1" color="#808080">{</font></div><div style="font-family: bookman old style, new york, times, serif;" dir="ltr" data-setdir="false"><font size="1" color="#808080">x1<-a[[i]]; x</font><span style="color: rgb(128, 128, 128); font-size: x-small;">2<-b[[j]]; x</span><span style="color: rgb(128, 128, 128); font-size: x-small;">3<-c[[k]]</span></div><div style="font-family: bookman old style, new york, times, serif;"><font size="1" color="#808080">baixa_bancos(x1,x2,x3)</font></div><div style="font-family: bookman old style, new york, times, serif;"><font size="1" color="#808080">}</font></div></div><br></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;">Coloquei interrogação no<font color="#cd232c"> vetor c em vermelho</font> por causa da dúvida. Os códigos de módulo e ano (óbvio) são fixos, basta vetorizar. Mas os códigos de realização de serviços trimestrais, identificados por código numérico, podem por conveniência de atraso, não ser iguais, embora sejam sempre quatro. Assim por exemplo:</div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;"><br></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif;"><font size="2" color="#cd232c">Mód:108;Ano:2020;codserv:1,2,3,5 </font></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif;"><span><span style="font-family: bookman old style, new york, times, serif;"><font size="2" color="#cd232c" style="background-color: inherit;">Mód:108;Ano:2021;codserv:1,2,3,4 </font></span></span></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif;"><span><span style="font-family: bookman old style, new york, times, serif;"><span><span style="font-family: bookman old style, new york, times, serif;"><font size="2" color="#cd232c" style="background-color: inherit;">Mód:429;Ano:2020;codserv:1,2,3,4</font></span></span></span></span></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif;"><span style="font-family: bookman old style, new york, times, serif;"><span style="font-family: bookman old style, new york, times, serif;"><span style="font-family: bookman old style, new york, times, serif;"><font size="2" style="background-color: inherit;" color="#cd232c">Mód:429;Ano:2021;codserv:1,3,4,5</font></span><br></span></span></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;"><br></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;">Dessa forma o vetor c depende do código de serviço e do ano em que ele foi realizado. Para me ajudar nisso, o TI daqui me deu uma outra consulta que também baixo por URL, que após alguns ajustes, faço virar uma tabela dentro do RStudio, com essa cara: <br></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;"><br></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;"><img title="Imagem incorporada" alt="Imagem incorporada" src="cid:2d680f76-8970-7572-0254-80f3e145056f@yahoo.com" class="yahoo-inline-image" draggable="false" style="max-width: 800px;" data-id="<2d680f76-8970-7572-0254-80f3e145056f@yahoo.com>"><br><span></span><br></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;">Resumindo agora: o que eu queria é adaptar meu código da seguinte forma: se viu que <span><span style="color: rgb(0, 0, 0); font-family: bookman old style, new york, times, serif; font-size: 16px;">o módulo é </span><b style="color: rgb(0, 0, 0); font-family: bookman old style, new york, times, serif; font-size: 16px;">108 </b></span>e o ano é <b>2020</b>, então ele deve ler como parâmetros para k3 o valores <i>1,2,3,5</i>; se for módulo <b>108</b> e ano <b>2021</b>, ele deve ler <span><span style="color: rgb(0, 0, 0); font-family: bookman old style, new york, times, serif; font-size: 16px;">para k3 o valores </span><i style="color: rgb(0, 0, 0); font-family: bookman old style, new york, times, serif; font-size: 16px;">1,2,3,4</i></span>. E assim sucessivamente, até finalizar o baixar das bases de dados requeridas.</div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;"><br></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;">Eu consegui ser claro? Se sim, alguém saberia como se faz isso?</div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;"><br></div><div dir="ltr" data-setdir="false" style="font-family: bookman old style, new york, times, serif; font-size: 16px;">Obrigado novamente pela disponibilidade do time!!! Att, </div><div class="ydpe2c28b33signature" style="font-family: bookman old style, new york, times, serif; font-size: 16px;"><div style="font-family:Helvetica, Arial, sans-serif;font-size:16px;"><div style="margin-bottom:0.0001pt;padding:0px;line-height:normal;background:white;"><i><span style="color:rgb(0, 0, 191);font-size:medium;"><font face="Courier New, courier, monaco, monospace, sans-serif" style="background-color: inherit;"><br></font></span></i></div><div style="margin-bottom:0.0001pt;padding:0px;line-height:normal;background:white;"><i id="ydpcf278505yui_3_16_0_1_1497025264182_38508"><span id="ydpcf278505yui_3_16_0_1_1497025264182_38507" style="color:rgb(0, 0, 191);font-size:medium;"><font face="Courier New, courier, monaco, monospace, sans-serif" style="background-color: inherit;">Diogo Jerônimo</font></span></i></div><div style="margin-bottom:0.0001pt;padding:0px;line-height:normal;background:white;"><i id="ydpcf278505yui_3_16_0_1_1497025264182_38430"><span id="ydpcf278505yui_3_16_0_1_1497025264182_38429" style="color:rgb(0, 0, 191);font-size:medium;"><font face="Courier New, courier, monaco, monospace, sans-serif" style="background-color: inherit;">Bacharel em Ciências Estatísticas - ENCE/IBGE</font></span></i></div><div style="margin-bottom:0.0001pt;padding:0px;line-height:normal;background:white;"><i id="ydpcf278505yui_3_16_0_1_1497025264182_38309"><span id="ydpcf278505yui_3_16_0_1_1497025264182_38308" style="color:rgb(0, 0, 191);font-size:medium;"><font face="Courier New, courier, monaco, monospace, sans-serif" style="background-color: inherit;">Mestre em Metrologia - PUC-Rio/PósMQI</font></span></i></div><div style="margin-bottom:0.0001pt;padding:0px;line-height:normal;background:white;"><i id="ydpcf278505yui_3_16_0_1_1497025264182_38323"><span id="ydpcf278505yui_3_16_0_1_1497025264182_38322" style="line-height:17.12px;color:rgb(0, 0, 191);font-size:medium;"><font face="Courier New, courier, monaco, monospace, sans-serif" id="ydpcf278505yui_3_16_0_1_1497025264182_38695" style="background-color: inherit;">http://lattes.cnpq.br/8996149312896520</font></span></i></div><p id="ydpcf278505yui_3_16_0_1_1497025264182_38326" style="margin-bottom:0.0001pt;padding:0px;line-height:normal;background:white;" class="ydpcf278505MsoNormal"><br></p></div></div></div></body></html>