<?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 Help with a if then statement. in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Help-with-a-if-then-statement/m-p/76447#M474</link>
    <description>I'm a new user to SAS and am in the process of updating someone elses code, for the most part no issues, except this one which has left me puzzled.  I'm running a data step that is adding new fields (only showing one in my example) and applying a formats run earlier as part of a Proc Format process.&lt;BR /&gt;
&lt;BR /&gt;
Issue:  When the process runs, only one of the formats is pickedup.  Meaning, all records regardless of bsnss_unt_id get the same format . . . any help would be appreciated  &lt;BR /&gt;
&lt;BR /&gt;
data Table5;&lt;BR /&gt;
set Table4;&lt;BR /&gt;
&lt;BR /&gt;
naalr_bnd = naalr_scr;&lt;BR /&gt;
&lt;BR /&gt;
/* groups naalr band */&lt;BR /&gt;
if bsnss_unt_id = 702 then do;	&lt;BR /&gt;
	  format naalr_bnd naalrs.;&lt;BR /&gt;
	end;&lt;BR /&gt;
	else if bsnss_unt_id = 803 then do;&lt;BR /&gt;
	  format naalr_bnd naalra.;&lt;BR /&gt;
	end;&lt;BR /&gt;
		&lt;BR /&gt;
run;&lt;BR /&gt;
endrsubmit;&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
value naalra&lt;BR /&gt;
0 - 0 = '01_000-000'&lt;BR /&gt;
1 - 349 = '02_001-349'&lt;BR /&gt;
350 - 354 = '03_350-354'&lt;BR /&gt;
355 - 359 = '04_355-359'&lt;BR /&gt;
360 - 364 = '05_360-364'&lt;BR /&gt;
365 - 369 = '06_365-369'&lt;BR /&gt;
370 - 374 = '07_370-374'&lt;BR /&gt;
375 - 379 = '08_375-379'&lt;BR /&gt;
380 - 384 = '09_380-384'&lt;BR /&gt;
385 - 389 = '10_385-389'&lt;BR /&gt;
390 - 394 = '11_390-394'&lt;BR /&gt;
395 - 399 = '12_395-399'&lt;BR /&gt;
400 - 404 = '13_400-404'&lt;BR /&gt;
405 - 409 = '14_405-409'&lt;BR /&gt;
410 - 414 = '15_410-414'&lt;BR /&gt;
415 - 419 = '16_415-419'&lt;BR /&gt;
420 - 424 = '17_420-424'&lt;BR /&gt;
425 - 429 = '18_425-429'&lt;BR /&gt;
430 - 434 = '19_430-434'&lt;BR /&gt;
435 - 439 = '20_435-439'&lt;BR /&gt;
440 - high= '21_440-999 '&lt;BR /&gt;
other = 'missing';&lt;BR /&gt;
&lt;BR /&gt;
value naalrs&lt;BR /&gt;
0 - 384 = '01_000-384'&lt;BR /&gt;
385 - 399 = '02_385-399'&lt;BR /&gt;
400 - 414 = '03_400-414'&lt;BR /&gt;
415 - 424 = '04_415-424'&lt;BR /&gt;
425 - 459 = '05_425-459'&lt;BR /&gt;
460 - high= '6_460+'&lt;BR /&gt;
other = 'missing';</description>
    <pubDate>Wed, 21 Oct 2009 20:34:54 GMT</pubDate>
    <dc:creator>NewUserFrank</dc:creator>
    <dc:date>2009-10-21T20:34:54Z</dc:date>
    <item>
      <title>Help with a if then statement.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Help-with-a-if-then-statement/m-p/76447#M474</link>
      <description>I'm a new user to SAS and am in the process of updating someone elses code, for the most part no issues, except this one which has left me puzzled.  I'm running a data step that is adding new fields (only showing one in my example) and applying a formats run earlier as part of a Proc Format process.&lt;BR /&gt;
&lt;BR /&gt;
Issue:  When the process runs, only one of the formats is pickedup.  Meaning, all records regardless of bsnss_unt_id get the same format . . . any help would be appreciated  &lt;BR /&gt;
&lt;BR /&gt;
data Table5;&lt;BR /&gt;
set Table4;&lt;BR /&gt;
&lt;BR /&gt;
naalr_bnd = naalr_scr;&lt;BR /&gt;
&lt;BR /&gt;
/* groups naalr band */&lt;BR /&gt;
if bsnss_unt_id = 702 then do;	&lt;BR /&gt;
	  format naalr_bnd naalrs.;&lt;BR /&gt;
	end;&lt;BR /&gt;
	else if bsnss_unt_id = 803 then do;&lt;BR /&gt;
	  format naalr_bnd naalra.;&lt;BR /&gt;
	end;&lt;BR /&gt;
		&lt;BR /&gt;
run;&lt;BR /&gt;
endrsubmit;&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
value naalra&lt;BR /&gt;
0 - 0 = '01_000-000'&lt;BR /&gt;
1 - 349 = '02_001-349'&lt;BR /&gt;
350 - 354 = '03_350-354'&lt;BR /&gt;
355 - 359 = '04_355-359'&lt;BR /&gt;
360 - 364 = '05_360-364'&lt;BR /&gt;
365 - 369 = '06_365-369'&lt;BR /&gt;
370 - 374 = '07_370-374'&lt;BR /&gt;
375 - 379 = '08_375-379'&lt;BR /&gt;
380 - 384 = '09_380-384'&lt;BR /&gt;
385 - 389 = '10_385-389'&lt;BR /&gt;
390 - 394 = '11_390-394'&lt;BR /&gt;
395 - 399 = '12_395-399'&lt;BR /&gt;
400 - 404 = '13_400-404'&lt;BR /&gt;
405 - 409 = '14_405-409'&lt;BR /&gt;
410 - 414 = '15_410-414'&lt;BR /&gt;
415 - 419 = '16_415-419'&lt;BR /&gt;
420 - 424 = '17_420-424'&lt;BR /&gt;
425 - 429 = '18_425-429'&lt;BR /&gt;
430 - 434 = '19_430-434'&lt;BR /&gt;
435 - 439 = '20_435-439'&lt;BR /&gt;
440 - high= '21_440-999 '&lt;BR /&gt;
other = 'missing';&lt;BR /&gt;
&lt;BR /&gt;
value naalrs&lt;BR /&gt;
0 - 384 = '01_000-384'&lt;BR /&gt;
385 - 399 = '02_385-399'&lt;BR /&gt;
400 - 414 = '03_400-414'&lt;BR /&gt;
415 - 424 = '04_415-424'&lt;BR /&gt;
425 - 459 = '05_425-459'&lt;BR /&gt;
460 - high= '6_460+'&lt;BR /&gt;
other = 'missing';</description>
      <pubDate>Wed, 21 Oct 2009 20:34:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Help-with-a-if-then-statement/m-p/76447#M474</guid>
      <dc:creator>NewUserFrank</dc:creator>
      <dc:date>2009-10-21T20:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a if then statement.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Help-with-a-if-then-statement/m-p/76448#M475</link>
      <description>It's quite sufficient to post a question/issue in only one forum.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 21 Oct 2009 23:10:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Help-with-a-if-then-statement/m-p/76448#M475</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-10-21T23:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a if then statement.</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Help-with-a-if-then-statement/m-p/76449#M476</link>
      <description>The format statement is not able to be issued conditionally the way you have done.&lt;BR /&gt;
&lt;BR /&gt;
if bsnss_unt_id = 702 then do;&lt;BR /&gt;
format naalr_bnd naalrs.;&lt;BR /&gt;
end;&lt;BR /&gt;
else if bsnss_unt_id = 803 then do;&lt;BR /&gt;
format naalr_bnd naalra.;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
You need to do something like&lt;BR /&gt;
&lt;BR /&gt;
if bsnss_unt_id = 702 then do;&lt;BR /&gt;
newvar=put( naalr_bnd, naalrs.);&lt;BR /&gt;
end;&lt;BR /&gt;
else if bsnss_unt_id = 803 then do;&lt;BR /&gt;
newvar=put( naalr_bnd naalra.);&lt;BR /&gt;
end;</description>
      <pubDate>Fri, 23 Oct 2009 02:44:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Help-with-a-if-then-statement/m-p/76449#M476</guid>
      <dc:creator>monei011</dc:creator>
      <dc:date>2009-10-23T02:44:54Z</dc:date>
    </item>
  </channel>
</rss>

