<?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 if then statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591746#M169574</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Please tell me what is wrong with this code;

Data Labtests.July1719_Test1a;
set Labtests.July1719_Tests;
if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Negative" then NAATG="Neg";
if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Positive" then NAATG="Pos";
if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="GC Negative" then CULG="Neg";
if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="GC Positive" then CULG="Pos";
if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="Not Applicable (e.g. Culture positive for N. Meningitides)" then NONGCG="Pos";
run;
the log says this.
1107  set Labtests.July1719_Tests;
1108  if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="GC nucleic acid amplification
1108! test (NAAT)" AND Result_1="GC Negative" then NAATG="Neg";
1109  if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="GC nucleic acid amplification
1109! test (NAAT)" AND Result_1="GC Positive" then NAATG="Pos";
1110  if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="GC
1110! Negative" then CULG="Neg";
1111  if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="GC
1111! Positive" then CULG="Pos";
1112  if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="Not
1112! Applicable (e.g. Culture positive for N. Meningitides)" then NONGCG="Pos";
1113  run;

NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      1108:29   1109:29   1110:29   1111:29   1112:29
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3313025 CollDate_1=11/10/2017 Specimen_1=Pharyngeal
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=1
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=3325056 CollDate_1=04/13/2018 Specimen_1=Pharyngeal TestType_1=Culture
Result_1=GC Negative F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=2
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=3443578 CollDate_1=10/02/2018 Specimen_1=Rectal TestType_1=Culture Result_1=GC Negative
F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=3
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3325011 CollDate_1=04/23/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=4
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3312054 CollDate_1=10/27/2017 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=6
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=2719247 CollDate_1=05/17/2017 Specimen_1=Pharyngeal TestType_1=Culture
Result_1=Not Applicable (e.g. Culture positive for N. Meningitides) F=  G=  H=  NAATG=  CULG=
NONGCG=  _ERROR_=1 _N_=8
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=2990718 CollDate_1=12/06/2017 Specimen_1=Pharyngeal TestType_1=Culture
Result_1=GC Negative F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=9
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=2935129 CollDate_1=10/12/2017 Specimen_1=Pharyngeal
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=13
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3100853 CollDate_1=02/19/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Positive F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=14
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3576407 CollDate_1=03/28/2019 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Positive F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=15
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3325029 CollDate_1=04/13/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=17
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=3497934 CollDate_1=01/15/2019 Specimen_1=Endocervical TestType_1=Culture
Result_1=GC Positive F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=18
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=2842778 CollDate_1=08/22/2017 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=19
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=3328919 CollDate_1=03/26/2018 Specimen_1=Pharyngeal TestType_1=Culture
Result_1=GC Negative F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=20
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=3283626 CollDate_1=05/01/2017 Specimen_1=Pharyngeal TestType_1=Culture
Result_1=GC Negative F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=21
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3325010 CollDate_1=04/05/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=23
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3157807 CollDate_1=04/12/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Positive F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=24
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3326691 CollDate_1=05/25/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=25
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3328907 CollDate_1=03/27/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=26
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
WARNING: Limit set by ERRORS= option reached.  Further errors of this type will not be printed.
IncidentID=3327668 CollDate_1=01/19/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=28
NOTE: There were 5395 observations read from the data set LABTESTS.JULY1719_TESTS.
NOTE: The data set LABTESTS.JULY1719_TEST1A has 5395 observations and 11 variables.
NOTE: DATA statement used (Total process time):
      real time           2.12 seconds
      cpu time            0.14 seconds


1114  proc freq data=Labtests.July1719_Test1a;
1115  table NAATG CULG NONGCG;
1116  run;

NOTE: There were 5395 observations read from the data set LABTESTS.JULY1719_TEST1A.
NOTE: PROCEDURE FREQ used (Total process time):
      real time           0.42 seconds
      cpu time            0.01 seconds

proc freq data=Labtests.July1719_Test1a;
table NAATG CULG NONGCG;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Sep 2019 02:54:15 GMT</pubDate>
    <dc:creator>Dhana18</dc:creator>
    <dc:date>2019-09-26T02:54:15Z</dc:date>
    <item>
      <title>if then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591746#M169574</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Please tell me what is wrong with this code;

Data Labtests.July1719_Test1a;
set Labtests.July1719_Tests;
if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Negative" then NAATG="Neg";
if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="GC nucleic acid amplification test (NAAT)" AND Result_1="GC Positive" then NAATG="Pos";
if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="GC Negative" then CULG="Neg";
if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="GC Positive" then CULG="Pos";
if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="Not Applicable (e.g. Culture positive for N. Meningitides)" then NONGCG="Pos";
run;
the log says this.
1107  set Labtests.July1719_Tests;
1108  if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="GC nucleic acid amplification
1108! test (NAAT)" AND Result_1="GC Negative" then NAATG="Neg";
1109  if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="GC nucleic acid amplification
1109! test (NAAT)" AND Result_1="GC Positive" then NAATG="Pos";
1110  if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="GC
1110! Negative" then CULG="Neg";
1111  if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="GC
1111! Positive" then CULG="Pos";
1112  if Specimen_1="Urethral" OR "Endocervical" AND TestType_1="Culture" AND Result_1="Not
1112! Applicable (e.g. Culture positive for N. Meningitides)" then NONGCG="Pos";
1113  run;

NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      1108:29   1109:29   1110:29   1111:29   1112:29
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3313025 CollDate_1=11/10/2017 Specimen_1=Pharyngeal
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=1
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=3325056 CollDate_1=04/13/2018 Specimen_1=Pharyngeal TestType_1=Culture
Result_1=GC Negative F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=2
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=3443578 CollDate_1=10/02/2018 Specimen_1=Rectal TestType_1=Culture Result_1=GC Negative
F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=3
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3325011 CollDate_1=04/23/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=4
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3312054 CollDate_1=10/27/2017 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=6
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=2719247 CollDate_1=05/17/2017 Specimen_1=Pharyngeal TestType_1=Culture
Result_1=Not Applicable (e.g. Culture positive for N. Meningitides) F=  G=  H=  NAATG=  CULG=
NONGCG=  _ERROR_=1 _N_=8
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=2990718 CollDate_1=12/06/2017 Specimen_1=Pharyngeal TestType_1=Culture
Result_1=GC Negative F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=9
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=2935129 CollDate_1=10/12/2017 Specimen_1=Pharyngeal
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=13
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3100853 CollDate_1=02/19/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Positive F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=14
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3576407 CollDate_1=03/28/2019 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Positive F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=15
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3325029 CollDate_1=04/13/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=17
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=3497934 CollDate_1=01/15/2019 Specimen_1=Endocervical TestType_1=Culture
Result_1=GC Positive F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=18
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=2842778 CollDate_1=08/22/2017 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=19
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=3328919 CollDate_1=03/26/2018 Specimen_1=Pharyngeal TestType_1=Culture
Result_1=GC Negative F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=20
NOTE: Invalid numeric data, 'Endocervical' , at line 1110 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1111 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1112 column 29.
IncidentID=3283626 CollDate_1=05/01/2017 Specimen_1=Pharyngeal TestType_1=Culture
Result_1=GC Negative F=  G=  H=  NAATG=  CULG=  NONGCG=  _ERROR_=1 _N_=21
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3325010 CollDate_1=04/05/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=23
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3157807 CollDate_1=04/12/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Positive F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=24
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3326691 CollDate_1=05/25/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=25
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
IncidentID=3328907 CollDate_1=03/27/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=26
NOTE: Invalid numeric data, 'Endocervical' , at line 1108 column 29.
NOTE: Invalid numeric data, 'Endocervical' , at line 1109 column 29.
WARNING: Limit set by ERRORS= option reached.  Further errors of this type will not be printed.
IncidentID=3327668 CollDate_1=01/19/2018 Specimen_1=Urine
TestType_1=GC nucleic acid amplification test (NAAT) Result_1=GC Negative F=  G=  H=  NAATG=
CULG=  NONGCG=  _ERROR_=1 _N_=28
NOTE: There were 5395 observations read from the data set LABTESTS.JULY1719_TESTS.
NOTE: The data set LABTESTS.JULY1719_TEST1A has 5395 observations and 11 variables.
NOTE: DATA statement used (Total process time):
      real time           2.12 seconds
      cpu time            0.14 seconds


1114  proc freq data=Labtests.July1719_Test1a;
1115  table NAATG CULG NONGCG;
1116  run;

NOTE: There were 5395 observations read from the data set LABTESTS.JULY1719_TEST1A.
NOTE: PROCEDURE FREQ used (Total process time):
      real time           0.42 seconds
      cpu time            0.01 seconds

proc freq data=Labtests.July1719_Test1a;
table NAATG CULG NONGCG;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Sep 2019 02:54:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591746#M169574</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2019-09-26T02:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: if then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591748#M169575</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; Specimen_1 in(&lt;SPAN class="token string"&gt;"Urethral",&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;"Endocervical)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;not&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; Specimen_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"Urethral"&lt;/SPAN&gt; OR &lt;SPAN class="token string"&gt;"Endocervical&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 03:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591748#M169575</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-26T03:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: if then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591749#M169576</link>
      <description>&lt;P&gt;Also if you ever need to use AND and OR in the same statement, using parentheses is compulsory to avoid confusion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; Specimen_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"Urethral"&lt;/SPAN&gt; OR Specimen_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;Endocervical"&lt;/SPAN&gt; AND TestType_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"Culture"&lt;/SPAN&gt; AND Result_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"GC Negative"&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; CULG&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"Neg"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is not the same as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; (Specimen_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"Urethral"&lt;/SPAN&gt; OR Specimen_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;Endocervical")&lt;/SPAN&gt; AND TestType_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"Culture"&lt;/SPAN&gt; AND Result_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"GC Negative"&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; CULG&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"Neg"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; Specimen_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"Urethral"&lt;/SPAN&gt; OR (Specimen_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;Endocervical"&lt;/SPAN&gt; AND TestType_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"Culture")&lt;/SPAN&gt; AND Result_1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"GC Negative"&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; CULG&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"Neg"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 03:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591749#M169576</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-26T03:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: if then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591798#M169599</link>
      <description>&lt;P&gt;Make your code easier to read and understand by grouping the conditions, and applying visual formatting:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Labtests.July1719_Test1a;
set Labtests.July1719_Tests;
if Specimen_1="Urethral" OR "Endocervical"
then do;
  if TestType_1="GC nucleic acid amplification test (NAAT)"
  then do;
    if Result_1="GC Negative" then NAATG="Neg";
    if Result_1="GC Positive" then NAATG="Pos";
  end;
  if TestType_1="Culture"
  then do;
    if Result_1="GC Negative" then CULG="Neg";
    if Result_1="GC Positive" then CULG="Pos";
    if Result_1="Not Applicable (e.g. Culture positive for N. Meningitides)" then NONGCG="Pos";
  end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Sep 2019 08:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591798#M169599</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-26T08:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: if then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591857#M169637</link>
      <description>&lt;P&gt;Apart from the obvious (OR connects logical statements, not strings) a good way to restructure your code could be with SELECT statements, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Labtests.July1719_Test1a;
  set Labtests.July1719_Tests;
  select(Specimen_1);
    when("Urethral","Endocervical") select(TestType_1);
	 when("GC nucleic acid amplification test (NAAT)") select(Result_1);
         when("GC Negative") NAATG="Neg";
         when("GC Positive") NAATG="Pos";
	 otherwise;
	 end;
      when("Culture") select(Result_1);
	when("GC Negative") CULG="Neg";
        when("GC Positive") CULG="Pos";
	when("Not Applicable (e.g. Culture positive for N. Meningitides)") NONGCG="Pos";
	otherwise;
	end;
      otherwise;
      end;
    otherwise;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;One of the nice things about the SELECT statements (apart from the fact that you can write a list of possible values like shown) is that you implicitly get the ELSE statements that are missing from your code - you will get the right results with some of the other suggestions (e.g. the one from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;), but things will run faster with large data if you use ELSE and not just repeated IF statements.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 13:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591857#M169637</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-09-26T13:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: if then statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591859#M169638</link>
      <description>Thank you! It worked!!&lt;BR /&gt;Have a great weekend.&lt;BR /&gt;</description>
      <pubDate>Thu, 26 Sep 2019 13:31:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-then-statement/m-p/591859#M169638</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2019-09-26T13:31:32Z</dc:date>
    </item>
  </channel>
</rss>

