<?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 How do I convert STATA code to SAS? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-convert-STATA-code-to-SAS/m-p/603716#M76482</link>
    <description>&lt;P&gt;Looking for help converting this STATA to SAS.&lt;/P&gt;&lt;PRE&gt;gen stillbirths = 0
label variable stillbirths "Stillbirths"
gen births = 0
label variable births "Births in calendar"
gen births2 = 0
label variable births2 "Births in birth history"

gen earlyneo = 0
label variable earlyneo "Early neonatal deaths"
gen &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths=0
label variable &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths "&lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt; deaths"
gen child_deaths=0
label variable child_deaths "child deaths"
gen beg = v018
gen end = v018+59
local vcal_len = strlen(vcal_1[1])
quietly forvalues i = 1/`vcal_len' {
replace births = births+1 if inrange(`i',beg,end) &amp;amp; substr(vcal_1,`i',1) == "B"
replace stillbirths = stillbirths+1 if inrange(`i',beg,end) &amp;amp; substr(vcal_1,`i',7) == "TPPPPPP" 
} 

replace end = v008
replace beg = v008-59

rename b3_0* b3_*
rename b6_0* b6_*
quietly forvalues i = 1/20 {
replace births2 = births2+1 if inrange(b3_`i',beg,end)
replace earlyneo = earlyneo+1 if inrange(b3_`i',beg,end) &amp;amp; inrange(b6_`i',100,106)
replace &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths = &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths+ 1 if inrange(b3_`i',beg,end) &amp;amp; inrange(b6_`i',100,211)
replace child_deaths = child_deaths+ 1 if inrange(b3_`i',beg,end) &amp;amp; inrange(b6_`i',212,304)
}&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;ZTH&lt;/P&gt;</description>
    <pubDate>Tue, 12 Nov 2019 21:44:39 GMT</pubDate>
    <dc:creator>ZTH</dc:creator>
    <dc:date>2019-11-12T21:44:39Z</dc:date>
    <item>
      <title>How do I convert STATA code to SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-convert-STATA-code-to-SAS/m-p/603716#M76482</link>
      <description>&lt;P&gt;Looking for help converting this STATA to SAS.&lt;/P&gt;&lt;PRE&gt;gen stillbirths = 0
label variable stillbirths "Stillbirths"
gen births = 0
label variable births "Births in calendar"
gen births2 = 0
label variable births2 "Births in birth history"

gen earlyneo = 0
label variable earlyneo "Early neonatal deaths"
gen &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths=0
label variable &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths "&lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt; deaths"
gen child_deaths=0
label variable child_deaths "child deaths"
gen beg = v018
gen end = v018+59
local vcal_len = strlen(vcal_1[1])
quietly forvalues i = 1/`vcal_len' {
replace births = births+1 if inrange(`i',beg,end) &amp;amp; substr(vcal_1,`i',1) == "B"
replace stillbirths = stillbirths+1 if inrange(`i',beg,end) &amp;amp; substr(vcal_1,`i',7) == "TPPPPPP" 
} 

replace end = v008
replace beg = v008-59

rename b3_0* b3_*
rename b6_0* b6_*
quietly forvalues i = 1/20 {
replace births2 = births2+1 if inrange(b3_`i',beg,end)
replace earlyneo = earlyneo+1 if inrange(b3_`i',beg,end) &amp;amp; inrange(b6_`i',100,106)
replace &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths = &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths+ 1 if inrange(b3_`i',beg,end) &amp;amp; inrange(b6_`i',100,211)
replace child_deaths = child_deaths+ 1 if inrange(b3_`i',beg,end) &amp;amp; inrange(b6_`i',212,304)
}&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;ZTH&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2019 21:44:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-convert-STATA-code-to-SAS/m-p/603716#M76482</guid>
      <dc:creator>ZTH</dc:creator>
      <dc:date>2019-11-12T21:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I convert STATA code to SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-I-convert-STATA-code-to-SAS/m-p/603787#M76485</link>
      <description>&lt;P&gt;Please describe the issue in logical form.&lt;/P&gt;
&lt;P&gt;Show us the data you have (ideally in a data step with daralines, so we can readily use it for testing), and what you expect out of it, according to your logical rules.&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/292576"&gt;@ZTH&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Looking for help converting this STATA to SAS.&lt;/P&gt;
&lt;PRE&gt;gen stillbirths = 0
label variable stillbirths "Stillbirths"
gen births = 0
label variable births "Births in calendar"
gen births2 = 0
label variable births2 "Births in birth history"

gen earlyneo = 0
label variable earlyneo "Early neonatal deaths"
gen &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths=0
label variable &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths "&lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt; deaths"
gen child_deaths=0
label variable child_deaths "child deaths"
gen beg = v018
gen end = v018+59
local vcal_len = strlen(vcal_1[1])
quietly forvalues i = 1/`vcal_len' {
replace births = births+1 if inrange(`i',beg,end) &amp;amp; substr(vcal_1,`i',1) == "B"
replace stillbirths = stillbirths+1 if inrange(`i',beg,end) &amp;amp; substr(vcal_1,`i',7) == "TPPPPPP" 
} 

replace end = v008
replace beg = v008-59

rename b3_0* b3_*
rename b6_0* b6_*
quietly forvalues i = 1/20 {
replace births2 = births2+1 if inrange(b3_`i',beg,end)
replace earlyneo = earlyneo+1 if inrange(b3_`i',beg,end) &amp;amp; inrange(b6_`i',100,106)
replace &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths = &lt;SPAN class="st0"&gt;infant&lt;/SPAN&gt;_deaths+ 1 if inrange(b3_`i',beg,end) &amp;amp; inrange(b6_`i',100,211)
replace child_deaths = child_deaths+ 1 if inrange(b3_`i',beg,end) &amp;amp; inrange(b6_`i',212,304)
}&lt;/PRE&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;ZTH&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2019 07:53:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-I-convert-STATA-code-to-SAS/m-p/603787#M76485</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-13T07:53:00Z</dc:date>
    </item>
  </channel>
</rss>

