<?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 Re: New column value derivation logic is not accounting for subsequent missing column value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859778#M339659</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the good insight.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I am looking for the code that outputs value to the new column based on the all/any true conditions. In simple terms, that is what the end users are looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Feb 2023 20:58:11 GMT</pubDate>
    <dc:creator>inquistive</dc:creator>
    <dc:date>2023-02-20T20:58:11Z</dc:date>
    <item>
      <title>New column value derivation logic is not accounting for subsequent missing column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/858621#M339239</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;
&lt;P&gt;Here is my code-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Review;
		length notes $50;
	set details; 
		if missing (student_id) then notes ="Student ID Missing";
		else if  missing(session_startdt) then notes="Session Start Date Missing";
		else if  missing(session_enddt) then notes ="Session End Date Missing";

		else if  missing(academic_year_startdt) then notes ="Academic  Year Start Date Missing";
		else if missing(academic_year_enddt) then notes="Academic Year  End Date Missing";
		else if missing(academic_year_startdt--academic_year_enddt) then notes= 'Both Dates Missing';

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the output-&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="inquistive_0-1676322096990.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80383iDD4C9AAA666F9BFA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="inquistive_0-1676322096990.png" alt="inquistive_0-1676322096990.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem here is the logic is outputting the notes value after evaluating the first missing condition( academic_year_startdt) is found. But it's not&amp;nbsp; capturing the next missing value( academic_year_enddt).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And also, it's not evaluating the condition-else if missing(academic_year_startdt---academic_year_enddt) then notes= 'Both Dates Missing', to output its defined value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you tell me what I am doing wrong ?What I am supposed to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 21:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/858621#M339239</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2023-02-13T21:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: New column value derivation logic is not accounting for subsequent missing column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/858634#M339243</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Review;
		length notes $50;
	set details; 
		if missing (student_id) then notes ="Student ID Missing";
		else if  missing(session_startdt) then notes="Session Start Date Missing";
		else if  missing(session_enddt) then notes ="Session End Date Missing";

		else if missing(academic_year_startdt) and missing(academic_year_enddt) then notes= 'Both Dates Missing';
		else if  missing(academic_year_startdt) then notes ="Academic  Year Start Date Missing";
		else if missing(academic_year_enddt) then notes="Academic Year  End Date Missing";


run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Feb 2023 22:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/858634#M339243</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-13T22:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: New column value derivation logic is not accounting for subsequent missing column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/858639#M339247</link>
      <description>&lt;P&gt;Personally if this were my data instead of trying to stuff multiple values into a single variable, considering that you may have cases where Session end date is missing as well as one of your Academic Year variables (which case you have not covered at all), have a bunch of flag variables, one for each variable/condition that you want reported.&lt;/P&gt;
&lt;P&gt;Something like this:&lt;/P&gt;
&lt;PRE&gt;data Review;
	set details; 
	n1 = missing (student_id);
	n2=  missing(session_startdt);
	n3= missing(session_enddt); 
	n4=  missing(academic_year_startdt); 
	n5= missing(academic_year_enddt);
   label 
      n1 ="Student ID Missing"
      n2 ="Session Start Date Missing"
      n3 ="Session End Date Missing"
      n4 ="Academic Year Start Date Missing"
      n5 ="Academic Year End Date Missing"
   ;
run;

proc format;
  value yn
  1='Yes'
  0='No'
run;

proc print data=review label;
   var n1-n5;
   format n1-n5 Yn.;
run;&lt;/PRE&gt;
&lt;P&gt;If you sum (of N1 - N5) you get number of problem variables per row. If you Mean(of N1-N5) you get decimal percentage of problems per observation. And a few other things similar are possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason I say "if this were my data" is that I have multiple projects that this a basic part of the data quality assurance reporting as well as a step to report result of interest for multiple variables.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 22:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/858639#M339247</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-13T22:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: New column value derivation logic is not accounting for subsequent missing column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859776#M339657</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thanks for the response.&lt;/P&gt;
&lt;P&gt;You modified the code and changed the order of the statements and put this first-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...else if missing (academic_year_startdt)and missing(academic_year_enddt) then notes= catx( "Both Dates Missing")...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and the program evaluated the first true condition and returned results.&amp;nbsp;&lt;SPAN&gt;But if you see the program, the following two conditions are also true:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;else if missing(academic_year_startdt) then notes ="Academic Year Start Date Missing";&lt;BR /&gt;else if missing(academic_year_enddt) then notes="Academic Year End Date Missing ";&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;Why is the program not evaluating those conditions(which are also true)? I want all the true conditions captured in the derived column as per the end users' preference .We can define the length of the newly derived column(Notes) from $50 to&amp;nbsp; $500, if needed to make space for the column value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 20:54:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859776#M339657</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2023-02-20T20:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: New column value derivation logic is not accounting for subsequent missing column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859778#M339659</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the good insight.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I am looking for the code that outputs value to the new column based on the all/any true conditions. In simple terms, that is what the end users are looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 20:58:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859778#M339659</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2023-02-20T20:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: New column value derivation logic is not accounting for subsequent missing column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859780#M339661</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Why is the program not evaluating those conditions(which are also true)?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Because IF-THEN-ELSE logic stops if the first IF statement is true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I want all the true conditions captured in the derived column as per the end users' preference&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So when both dates are missing, you want three text strings for that student? What would that look like? Why are three necessary when 'Both Dates Missing' is a complete description of the situation, other text is redundant.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 21:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859780#M339661</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-20T21:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: New column value derivation logic is not accounting for subsequent missing column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859785#M339663</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Agreed ('&lt;SPAN&gt;IF-THEN-ELSE logic stops if the first IF statement is true&lt;/SPAN&gt;') . What about the following condition where the values/strings are not redundant?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="inquistive_0-1676927787965.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80623i9856B758427FED5C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="inquistive_0-1676927787965.png" alt="inquistive_0-1676927787965.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data modify;
		length notes $200;
	set review; 
		if missing (student_id) then notes ="Student ID Missing";
		else if  missing(session_startdt) then notes="Session Start Date Missing";
		else if  missing(session_enddt) then notes ="Session End Date Missing";
		else if missing(academic_year_startdt) and missing (academic_year_enddt) then notes= 'Both Dates Missing';
		else if  missing(academic_year_enddt) then notes ="Academic  Year Start Date Missing";
		else if missing(academic_year_enddt) then notes="Academic Year  End Date Missing";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the result.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="inquistive_1-1676928015235.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80624iDC8E6592F654A745/image-size/medium?v=v2&amp;amp;px=400" role="button" title="inquistive_1-1676928015235.png" alt="inquistive_1-1676928015235.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It's still processing only the first true condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 21:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859785#M339663</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2023-02-20T21:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: New column value derivation logic is not accounting for subsequent missing column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859786#M339664</link>
      <description>&lt;P&gt;Okay, I think it is time for you to be very very specific here. What is the desired value of NOTES in each situation? You can write it out in plain English if necessary.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 21:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859786#M339664</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-20T21:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: New column value derivation logic is not accounting for subsequent missing column value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859790#M339666</link>
      <description>&lt;P&gt;Untested, because you didn't post test data.&amp;nbsp; If you want the NOTES variable to have, say a pipe-delimited list of all the missing value notes that apply for a record, you could play with stuff like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if missing(student_id)      then notes=catx("|",notes,"Student ID Missing") ;
if missing(session_startdt) then notes=catx("|",notes,"Session Start Date Missing") ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if you want more "human readable" it could be an AND-delimited list:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if missing(student_id)      then notes=catx(" and ",notes,"Student ID Missing");
if missing(session_startdt) then notes=catx(" and ",notes,"Session Start Date Missing");
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you've got a lot of these, you could use an array, and if the variables have labels you could use the label to generate the text for the note, rather than hard-coding it.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 21:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-column-value-derivation-logic-is-not-accounting-for/m-p/859790#M339666</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-02-20T21:53:44Z</dc:date>
    </item>
  </channel>
</rss>

