<?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: Creating a new data set with &amp;quot;updated&amp;quot; personal information from a csv file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-with-quot-updated-quot-personal/m-p/473530#M121534</link>
    <description>&lt;P&gt;Thank you so much! I have never heard of this command before. I really appreciate it!&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jun 2018 19:34:09 GMT</pubDate>
    <dc:creator>awardell</dc:creator>
    <dc:date>2018-06-26T19:34:09Z</dc:date>
    <item>
      <title>Creating a new data set with "updated" personal information from a csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-with-quot-updated-quot-personal/m-p/473501#M121521</link>
      <description>&lt;P&gt;Hello! I am trying to figure out how to create a data set from a csv file from excel (containing personal information and its updates). The new dataset will contain only the updated personal information. I am using SAS 9.4&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The file in excel has variables such as "First_Name Last_name Address_1 Address_2 City State Zip Phone ...... 2_address_1 2_address_2 2_city 2_state 2_zip 2_phone ..... 10_phone"&amp;nbsp;&lt;/P&gt;&lt;P&gt;where each: phone 2_phone 3_phone... etc is an updated telephone number.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create code that will pick the most recent phone number and store it in a variable called "updated_phone".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know how to create the data set once I get the variables "updated_phone, updated_zip, etc" working, but I am having trouble figuring out an efficient way to make the updated_phone variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried it using a huge if then else statement, but I was hoping there is a more efficient way that I am not seeing.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have for example: (but I would love to do it a way that is more succinct)&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if _10_phone = " " AND _9_phone = " " AND _8_phone = " " AND _7_phone = " "
		AND _6_phone = " " AND _5_phone = " " AND _4_phone = " " AND _3_phone = " "
		AND _2_phone = " " then p_count=1; 
	else if _10_phone = " " AND _9_phone = " " AND _8_phone = " " AND _7_phone = " "
		AND _6_phone = " " AND _5_phone = " " AND _4_phone = " " AND _3_phone = " "
		AND _2_phone ^= " " then p_count =2 ; 
	else if _10_phone = " " AND _9_phone = " " AND _8_phone = " " AND _7_phone = " "
		AND _6_phone = " " AND _5_phone = " " AND _4_phone = " " AND _3_phone ^= " "
		AND _2_phone ^= " " then p_count =3 ; 
	else if _10_phone = " " AND _9_phone = " " AND _8_phone = " " AND _7_phone = " "
		AND _6_phone = " " AND _5_phone = " " AND _4_phone ^= " " AND _3_phone ^= " "
		AND _2_phone ^= " " then p_count =4 ; 
	else if _10_phone = " " AND _9_phone = " " AND _8_phone = " " AND _7_phone = " "
		AND _6_phone = " " AND _5_phone ^= " " AND _4_phone ^= " " AND _3_phone ^= " "
		AND _2_phone ^= " " then p_count =5 ; 
	else if _10_phone = " " AND _9_phone = " " AND _8_phone = " " AND _7_phone = " "
		AND _6_phone ^= " " AND _5_phone ^= " " AND _4_phone ^= " " AND _3_phone ^= " "
		AND _2_phone ^= " " then p_count =6 ; 
	else if _10_phone = " " AND _9_phone = " " AND _8_phone = " " AND _7_phone ^= " "
		AND _6_phone ^= " " AND _5_phone ^= " " AND _4_phone ^= " " AND _3_phone ^= " "
		AND _2_phone ^= " " then p_count =7 ; 
	else if _10_phone = " " AND _9_phone = " " AND _8_phone ^= " " AND _7_phone ^= " "
		AND _6_phone ^= " " AND _5_phone ^= " " AND _4_phone ^= " " AND _3_phone ^= " "
		AND _2_phone ^= " " then p_count =8 ; 
	else if _10_phone = " " AND _9_phone ^= " " AND _8_phone ^= " " AND _7_phone ^= " "
		AND _6_phone ^= " " AND _5_phone ^= " " AND _4_phone ^= " " AND _3_phone ^= " "
		AND _2_phone ^= " " then p_count =9 ; 
	else if _10_phone = " " AND _9_phone ^= " " AND _8_phone ^= " " AND _7_phone ^= " "
		AND _6_phone ^= " " AND _5_phone ^= " " AND _4_phone ^= " " AND _3_phone ^= " "
		AND _2_phone ^= " " then p_count =10 ; 
	
	if p_count=1 then updated_phone= phone; 
	else if p_count=2 then updated_phone = _2_phone; 
	else if p_count=3 then updated_phone = _3_phone; 
	else if p_count=4 then updated_phone = _4_phone; 
	else if p_count=5 then updated_phone = _5_phone; 
	else if p_count=6 then updated_phone = _6_phone; 
	else if p_count=7 then updated_phone = _7_phone; 
	else if p_count=8 then updated_phone = _8_phone; 
	else if p_count=9 then updated_phone = _9_phone; 
	else if p_count=10 then updated_phone = _10_phone; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thanks for all the help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 18:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-with-quot-updated-quot-personal/m-p/473501#M121521</guid>
      <dc:creator>awardell</dc:creator>
      <dc:date>2018-06-26T18:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new data set with "updated" personal information from a csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-with-quot-updated-quot-personal/m-p/473522#M121529</link>
      <description>&lt;P&gt;And yet another example of why the typical Excel creation is poorly structured and hard to work with.&lt;/P&gt;
&lt;P&gt;If this set were structured:&lt;/P&gt;
&lt;P&gt;First_Name Last_name Address_1 Address_2 City State Zip Phone&lt;/P&gt;
&lt;P&gt;with a separate row for each additional address, city state zip, phone the exercise is practically trivial.&lt;/P&gt;
&lt;P&gt;You do not need to go through any of that to get counts or such&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   phone = '111-1111';
_2_phone = '222-2222';
_3_phone = '333-3333';
_4_phone = '444-4444';
_5_phone = '555-5555';
_6_phone = '        ';
_7_phone = '        ';
_8_phone = '        ';
_9_phone = '        ';
_10_phone = '        ';
   
newphone = coalescec(_10_phone,_9_phone,_8_phone,_7_phone,_6_phone,_5_phone,_4_phone,_3_phone,_2_phone,phone);
run;
&lt;/PRE&gt;
&lt;P&gt;the COALESCEC (or COALESCE for numeric values) returns the first non-missing value from left to right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 19:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-with-quot-updated-quot-personal/m-p/473522#M121529</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-26T19:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new data set with "updated" personal information from a csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-with-quot-updated-quot-personal/m-p/473530#M121534</link>
      <description>&lt;P&gt;Thank you so much! I have never heard of this command before. I really appreciate it!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 19:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-with-quot-updated-quot-personal/m-p/473530#M121534</guid>
      <dc:creator>awardell</dc:creator>
      <dc:date>2018-06-26T19:34:09Z</dc:date>
    </item>
  </channel>
</rss>

