<?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 convert STATA codes to SAS codes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-STATA-codes-to-SAS-codes/m-p/663849#M198251</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My collaborator sent me his Stata codes. I only use SAS so need help to convert STATA codes to SAS codes for a longitudinal data variable:&lt;/P&gt;&lt;P&gt;Following are his codes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;forvalues i=1/13{&lt;/P&gt;&lt;P&gt;gen r`i'ins=1 if r`i'higov==1&lt;/P&gt;&lt;P&gt;replace r`i'ins=2 if r`i'higov==1 &amp;amp; r`i'covr==1&lt;/P&gt;&lt;P&gt;replace r`i'ins=2 if r`i'higov==1 &amp;amp; r`i'covs==1&lt;/P&gt;&lt;P&gt;replace r`i'ins=3 if r`i'higov==1 &amp;amp; r`i'hiothp==1&lt;/P&gt;&lt;P&gt;replace r`i'ins=4 if (r`i'covr==1 | r`i'covs==1) &amp;amp; r`i'ins==.&lt;/P&gt;&lt;P&gt;replace r`i'ins=5 if r`i'hiothp==1 &amp;amp; r`i'ins==.&lt;/P&gt;&lt;P&gt;replace r`i'ins=6 if r`i'higov==0 &amp;amp; r`i'covr==0 &amp;amp; r`i'covs==0 &amp;amp; r`i'hiothp==0&lt;/P&gt;&lt;P&gt;capture label define r`i'ins 1"Government Insurance Only" 2"Governemnt and Employer" ///&lt;/P&gt;&lt;P&gt;3"Government and Other" 4"Employer Only" 5"Other Only" 6"No Insurance"&lt;/P&gt;&lt;P&gt;label value r`i'ins r`i'ins&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your help.&lt;/P&gt;</description>
    <pubDate>Sun, 21 Jun 2020 16:46:11 GMT</pubDate>
    <dc:creator>cjlin2020</dc:creator>
    <dc:date>2020-06-21T16:46:11Z</dc:date>
    <item>
      <title>convert STATA codes to SAS codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-STATA-codes-to-SAS-codes/m-p/663849#M198251</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My collaborator sent me his Stata codes. I only use SAS so need help to convert STATA codes to SAS codes for a longitudinal data variable:&lt;/P&gt;&lt;P&gt;Following are his codes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;forvalues i=1/13{&lt;/P&gt;&lt;P&gt;gen r`i'ins=1 if r`i'higov==1&lt;/P&gt;&lt;P&gt;replace r`i'ins=2 if r`i'higov==1 &amp;amp; r`i'covr==1&lt;/P&gt;&lt;P&gt;replace r`i'ins=2 if r`i'higov==1 &amp;amp; r`i'covs==1&lt;/P&gt;&lt;P&gt;replace r`i'ins=3 if r`i'higov==1 &amp;amp; r`i'hiothp==1&lt;/P&gt;&lt;P&gt;replace r`i'ins=4 if (r`i'covr==1 | r`i'covs==1) &amp;amp; r`i'ins==.&lt;/P&gt;&lt;P&gt;replace r`i'ins=5 if r`i'hiothp==1 &amp;amp; r`i'ins==.&lt;/P&gt;&lt;P&gt;replace r`i'ins=6 if r`i'higov==0 &amp;amp; r`i'covr==0 &amp;amp; r`i'covs==0 &amp;amp; r`i'hiothp==0&lt;/P&gt;&lt;P&gt;capture label define r`i'ins 1"Government Insurance Only" 2"Governemnt and Employer" ///&lt;/P&gt;&lt;P&gt;3"Government and Other" 4"Employer Only" 5"Other Only" 6"No Insurance"&lt;/P&gt;&lt;P&gt;label value r`i'ins r`i'ins&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your help.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jun 2020 16:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-STATA-codes-to-SAS-codes/m-p/663849#M198251</guid>
      <dc:creator>cjlin2020</dc:creator>
      <dc:date>2020-06-21T16:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: convert STATA codes to SAS codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-STATA-codes-to-SAS-codes/m-p/664090#M198355</link>
      <description>&lt;P&gt;Ask your&amp;nbsp;&lt;SPAN&gt;collaborator&amp;nbsp;what this does and we'll try to help.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It looks like just a few tests.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 22:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-STATA-codes-to-SAS-codes/m-p/664090#M198355</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-22T22:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: convert STATA codes to SAS codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-STATA-codes-to-SAS-codes/m-p/664468#M198508</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The Stata codes were to generate a new insurance categorical variable (r{*}ins, i is from 1 to 13) within each study id repeating for 13 years which is a long form of data.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is what I have figured out:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;Using the first year (r1ins) as an example:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;r1ins=.;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;If&amp;nbsp;r1higov =1, then&amp;nbsp;r1ins = 1;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;ELSE If (r1higov =1 &amp;amp;&amp;nbsp;r1covr=1) or if (r1higov=1 &amp;amp; r1covs=1) then&amp;nbsp;r1ins = 2;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;ELSE If (r1higov=1 &amp;amp; r1hiothp=1) then&amp;nbsp;r1ins = 3;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;ELSE If&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;(r1covr=1 or r1covs=1) and (r1ins is missing) then&amp;nbsp;r1ins = 4;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;ELSE If&amp;nbsp;(r1hiothp=1 &amp;amp; r1ins is missing)&amp;nbsp; then&amp;nbsp;r1ins = 5;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;ELSE If&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;r1higov=0 &amp;amp; r1covr=0 &amp;amp; r1covs=0 &amp;amp; r1hiothp=0 then&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;r1ins = 6;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;The last part of the Stata codes were to format the riins, which can be converted to following&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;&amp;nbsp;SAS codes:&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;PROC FORMAT;&lt;BR /&gt;VALUE ins_fmt&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 = "Government Insurance Only"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 = "Government Insurance and Employer"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 = "Government Insurance and Other"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 = "Employer Only"&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 = "Other only"&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino"&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6 = "No Insurance";&lt;BR /&gt;RUN;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still need help to write the SAS codes for all 13 years within each study id.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 20:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-STATA-codes-to-SAS-codes/m-p/664468#M198508</guid>
      <dc:creator>cjlin2020</dc:creator>
      <dc:date>2020-06-23T20:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: convert STATA codes to SAS codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-STATA-codes-to-SAS-codes/m-p/664474#M198514</link>
      <description>&lt;P&gt;ARRAY processing should solve your problem. What is the naming pattern for your variables? Is it something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array rhigovs (13) r1higov r2higov r3higov r4higov r5higov r6higov
                   r7higov r8higov r9higov r10higov r11higov r12higov r13higov;
array rins (13) r1ins......................r13ins;
do i = 1 to dim(rhigovs);
&amp;lt;put your array logic here.&amp;gt;
if rhigovs(i) = 1 then rins(i) = 1;
&amp;lt;etc&amp;gt;
end;&lt;/CODE&gt;&lt;/PRE&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>Tue, 23 Jun 2020 20:21:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-STATA-codes-to-SAS-codes/m-p/664474#M198514</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-06-23T20:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: convert STATA codes to SAS codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-STATA-codes-to-SAS-codes/m-p/664649#M198598</link>
      <description>&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 14:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-STATA-codes-to-SAS-codes/m-p/664649#M198598</guid>
      <dc:creator>cjlin2020</dc:creator>
      <dc:date>2020-06-24T14:47:53Z</dc:date>
    </item>
  </channel>
</rss>

