<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Coverter: From R + Spark Code to Proc SAS in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583296#M28604</link>
    <description>&lt;P&gt;Could someone who comes from R language and SAS programming help me? I need to execute the code below programmatically in SAS. The code below was developed in R Spark on databricks. The goal is to run SAS through PROC, but as is little known in SAS Transfers. If anyone can help me with any suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;6&lt;BR /&gt;for(i in 1:nrow(distinct_cluster)){&lt;BR /&gt;grupo=distinct_cluster[[i]]&lt;/P&gt;&lt;P&gt;dados&amp;lt;-dados_cluster&lt;BR /&gt;dados&amp;lt;-dados%&amp;gt;%filter(grupos==grupo)&lt;BR /&gt;&lt;BR /&gt;variaveis_clusters &amp;lt;- dados %&amp;gt;%&lt;BR /&gt;filter(DATIPRNOTFSC&amp;lt;'2019-01-01', DATIPRNOTFSC&amp;gt;='2018-01-01')%&amp;gt;%&lt;BR /&gt;group_by(DESATICLI, Calculation)%&amp;gt;%&lt;BR /&gt;summarize(qtde=n())%&amp;gt;%&lt;BR /&gt;sdf_pivot(DESATICLI ~ Calculation, fun.aggregate = list(qtde = "sum"))&lt;/P&gt;&lt;P&gt;stats &amp;lt;- variaveis_clusters %&amp;gt;% select(-DESATICLI) %&amp;gt;% summarise_all(funs(avg, min, max)) %&amp;gt;% collect()&lt;/P&gt;&lt;P&gt;cols &amp;lt;- variaveis_clusters%&amp;gt;% select(-DESATICLI) %&amp;gt;% colnames()&lt;BR /&gt;avgs &amp;lt;- stats %&amp;gt;% select(ends_with("avg")) %&amp;gt;% unlist&lt;BR /&gt;mins &amp;lt;- stats %&amp;gt;% select(ends_with("min")) %&amp;gt;% unlist&lt;BR /&gt;maxs &amp;lt;- stats %&amp;gt;% select(ends_with("max")) %&amp;gt;% unlist&lt;/P&gt;&lt;P&gt;exprs &amp;lt;- glue("(`{cols}` - {avgs}) / ({maxs} - {mins})") %&amp;gt;%&lt;BR /&gt;setNames(cols) %&amp;gt;%&lt;BR /&gt;lapply(parse_quosure)&lt;/P&gt;&lt;P&gt;variaveis_escaladas&amp;lt;-variaveis_clusters %&amp;gt;% mutate(!!! exprs)&lt;/P&gt;&lt;P&gt;variaveis_clusters_tratado &amp;lt;- na.replace(variaveis_escaladas,0)&lt;BR /&gt;variaveis_clusters_tratado &amp;lt;- sdf_copy_to(sc, variaveis_clusters_tratado,&lt;BR /&gt;name = "variaveis_clusters_tratado", overwrite = TRUE)&lt;/P&gt;&lt;P&gt;set.seed(364221)&lt;/P&gt;&lt;P&gt;cluster &amp;lt;- ml_kmeans(variaveis_clusters_tratado, DESATICLI ~ ., k = 6)&lt;/P&gt;&lt;P&gt;clusters &amp;lt;- ml_predict(cluster, variaveis_clusters_tratado)&lt;/P&gt;&lt;P&gt;clusters &amp;lt;- clusters%&amp;gt;%mutate(grupos = case_when(&lt;BR /&gt;prediction==0 ~ "A",&lt;BR /&gt;prediction==1 ~ "B",&lt;BR /&gt;prediction==2 ~ "C",&lt;BR /&gt;prediction==3 ~ "D",&lt;BR /&gt;prediction==4 ~ "E",&lt;BR /&gt;prediction==5 ~ "F"))&lt;BR /&gt;if(i==1){&lt;BR /&gt;saida&amp;lt;-clusters%&amp;gt;%select(DESATICLI,grupos)%&amp;gt;%mutate(grupos_1=grupo)&lt;BR /&gt;}else{&lt;BR /&gt;saida&amp;lt;-sdf_bind_rows(saida,clusters%&amp;gt;%select(DESATICLI,grupos)%&amp;gt;%mutate(grupos_1=grupo))&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
    <pubDate>Thu, 22 Aug 2019 18:34:21 GMT</pubDate>
    <dc:creator>EloarL</dc:creator>
    <dc:date>2019-08-22T18:34:21Z</dc:date>
    <item>
      <title>Coverter: From R + Spark Code to Proc SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583296#M28604</link>
      <description>&lt;P&gt;Could someone who comes from R language and SAS programming help me? I need to execute the code below programmatically in SAS. The code below was developed in R Spark on databricks. The goal is to run SAS through PROC, but as is little known in SAS Transfers. If anyone can help me with any suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;6&lt;BR /&gt;for(i in 1:nrow(distinct_cluster)){&lt;BR /&gt;grupo=distinct_cluster[[i]]&lt;/P&gt;&lt;P&gt;dados&amp;lt;-dados_cluster&lt;BR /&gt;dados&amp;lt;-dados%&amp;gt;%filter(grupos==grupo)&lt;BR /&gt;&lt;BR /&gt;variaveis_clusters &amp;lt;- dados %&amp;gt;%&lt;BR /&gt;filter(DATIPRNOTFSC&amp;lt;'2019-01-01', DATIPRNOTFSC&amp;gt;='2018-01-01')%&amp;gt;%&lt;BR /&gt;group_by(DESATICLI, Calculation)%&amp;gt;%&lt;BR /&gt;summarize(qtde=n())%&amp;gt;%&lt;BR /&gt;sdf_pivot(DESATICLI ~ Calculation, fun.aggregate = list(qtde = "sum"))&lt;/P&gt;&lt;P&gt;stats &amp;lt;- variaveis_clusters %&amp;gt;% select(-DESATICLI) %&amp;gt;% summarise_all(funs(avg, min, max)) %&amp;gt;% collect()&lt;/P&gt;&lt;P&gt;cols &amp;lt;- variaveis_clusters%&amp;gt;% select(-DESATICLI) %&amp;gt;% colnames()&lt;BR /&gt;avgs &amp;lt;- stats %&amp;gt;% select(ends_with("avg")) %&amp;gt;% unlist&lt;BR /&gt;mins &amp;lt;- stats %&amp;gt;% select(ends_with("min")) %&amp;gt;% unlist&lt;BR /&gt;maxs &amp;lt;- stats %&amp;gt;% select(ends_with("max")) %&amp;gt;% unlist&lt;/P&gt;&lt;P&gt;exprs &amp;lt;- glue("(`{cols}` - {avgs}) / ({maxs} - {mins})") %&amp;gt;%&lt;BR /&gt;setNames(cols) %&amp;gt;%&lt;BR /&gt;lapply(parse_quosure)&lt;/P&gt;&lt;P&gt;variaveis_escaladas&amp;lt;-variaveis_clusters %&amp;gt;% mutate(!!! exprs)&lt;/P&gt;&lt;P&gt;variaveis_clusters_tratado &amp;lt;- na.replace(variaveis_escaladas,0)&lt;BR /&gt;variaveis_clusters_tratado &amp;lt;- sdf_copy_to(sc, variaveis_clusters_tratado,&lt;BR /&gt;name = "variaveis_clusters_tratado", overwrite = TRUE)&lt;/P&gt;&lt;P&gt;set.seed(364221)&lt;/P&gt;&lt;P&gt;cluster &amp;lt;- ml_kmeans(variaveis_clusters_tratado, DESATICLI ~ ., k = 6)&lt;/P&gt;&lt;P&gt;clusters &amp;lt;- ml_predict(cluster, variaveis_clusters_tratado)&lt;/P&gt;&lt;P&gt;clusters &amp;lt;- clusters%&amp;gt;%mutate(grupos = case_when(&lt;BR /&gt;prediction==0 ~ "A",&lt;BR /&gt;prediction==1 ~ "B",&lt;BR /&gt;prediction==2 ~ "C",&lt;BR /&gt;prediction==3 ~ "D",&lt;BR /&gt;prediction==4 ~ "E",&lt;BR /&gt;prediction==5 ~ "F"))&lt;BR /&gt;if(i==1){&lt;BR /&gt;saida&amp;lt;-clusters%&amp;gt;%select(DESATICLI,grupos)%&amp;gt;%mutate(grupos_1=grupo)&lt;BR /&gt;}else{&lt;BR /&gt;saida&amp;lt;-sdf_bind_rows(saida,clusters%&amp;gt;%select(DESATICLI,grupos)%&amp;gt;%mutate(grupos_1=grupo))&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 18:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583296#M28604</guid>
      <dc:creator>EloarL</dc:creator>
      <dc:date>2019-08-22T18:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Coverter: From R + Spark Code to Proc SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583304#M28605</link>
      <description>&lt;P&gt;Could you explain what the code does?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you looked into the R-interface in SAS which is available through IML/Studio?&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=imlsstat&amp;amp;docsetTarget=imlsstat_statr_toc.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=imlsstat&amp;amp;docsetTarget=imlsstat_statr_toc.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 19:08:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583304#M28605</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-22T19:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Coverter: From R + Spark Code to Proc SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583317#M28606</link>
      <description>What exactly do you need help with? &lt;BR /&gt;&lt;BR /&gt;Are you trying to convert the code to SAS code, to use SAS to pass the code to R/Spark or something else?&lt;BR /&gt;&lt;BR /&gt;The code isn't actually bad at all, you need PROC MEANS mostly, possibly a transpose and data step but most of it is pretty straightforward data management processes. Note that because you have a SEED and randomness to some of the data you can't necessarily exactly replicate the full clustering process.&lt;BR /&gt;&lt;BR /&gt;PS if databricks can export a PMML model certain SAS products can injest that and do the conversion. PMML is severely underutilized IMO.</description>
      <pubDate>Thu, 22 Aug 2019 19:33:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583317#M28606</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-22T19:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Coverter: From R + Spark Code to Proc SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583329#M28607</link>
      <description>I am trying to convert the code into SAS code for use in SAS GUIDE OR MINER.</description>
      <pubDate>Thu, 22 Aug 2019 20:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583329#M28607</guid>
      <dc:creator>EloarL</dc:creator>
      <dc:date>2019-08-22T20:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Coverter: From R + Spark Code to Proc SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583331#M28608</link>
      <description>Ok. So what specfically do you need help with. I can outline some steps but will not do the coding for you - how familliar are you with SAS? Are you familiar with PROC MEANS and FREQ?</description>
      <pubDate>Thu, 22 Aug 2019 20:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583331#M28608</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-22T20:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Coverter: From R + Spark Code to Proc SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583333#M28609</link>
      <description>What I have with the frequency of code to execute in SAS refers to the command that was used at the beginning of the code. The command refers to executing the code 6 times for a quantity of 6 didnt groups. ie I don't know which command to use in SAS to perform retries n times. This is my difficulty.</description>
      <pubDate>Thu, 22 Aug 2019 20:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583333#M28609</guid>
      <dc:creator>EloarL</dc:creator>
      <dc:date>2019-08-22T20:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Coverter: From R + Spark Code to Proc SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583350#M28610</link>
      <description>&lt;P&gt;Get it running for one set and then we can help you convert it to run for all groups.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are generally several ways, two of the most common are BY group and macros.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd say read up a bit on BY group processing in SAS - it's like GROUP BY in R, but think of it as being available to all your packages - including the cluster proc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=n138da4gme3zb7n1nifpfhqv7clq.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=n138da4gme3zb7n1nifpfhqv7clq.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And another is macros, which are similar to functions except assume they return nothing just do a specific set of tasks.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284234"&gt;@EloarL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;What I have with the frequency of code to execute in SAS refers to the command that was used at the beginning of the code. The command refers to executing the code 6 times for a quantity of 6 didnt groups. ie I don't know which command to use in SAS to perform retries n times. This is my difficulty.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 22:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583350#M28610</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-22T22:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Coverter: From R + Spark Code to Proc SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583443#M28613</link>
      <description>I understand ... thank you very much for the suggestions.</description>
      <pubDate>Fri, 23 Aug 2019 12:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583443#M28613</guid>
      <dc:creator>EloarL</dc:creator>
      <dc:date>2019-08-23T12:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Coverter: From R + Spark Code to Proc SAS</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583561#M28616</link>
      <description>&lt;P&gt;It may help to provide a small data set as SAS data step code and what the desired output would be from the given R code for that example data set. The data set needs to be just big enough or complex enough to exercise all of the options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2019 17:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Coverter-From-R-Spark-Code-to-Proc-SAS/m-p/583561#M28616</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-23T17:33:19Z</dc:date>
    </item>
  </channel>
</rss>

