<?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: Retrieving information about the highest degree earned in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retrieving-information-about-the-highest-degree-earned/m-p/566838#M159370</link>
    <description>&lt;P&gt;Comments / questions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Is your data already contained in a SAS data set?&amp;nbsp; That's a necessary starting point.&lt;/LI&gt;
&lt;LI&gt;What is the name of the data set?&lt;/LI&gt;
&lt;LI&gt;What are the names of the variables in the data set?&amp;nbsp; Column numbers don't help.&lt;/LI&gt;
&lt;LI&gt;Don't plan on using a dot as part of a variable name.&amp;nbsp; Use PhD_New instead of Ph.D_New&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Tue, 18 Jun 2019 12:37:14 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-06-18T12:37:14Z</dc:date>
    <item>
      <title>Retrieving information about the highest degree earned</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retrieving-information-about-the-highest-degree-earned/m-p/566815#M159365</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset where each row contains information for an individual and the columns show that individual's academic degrees. So column1 is the individual's ID, column2 is Name of the individual. Column 3, 4, and 5 are for Undergrad, Grad, and Ph.D. degrees. Column 3, 4, and 5 take a value "1" if the individual holds a degree of the respective column, and 0 otherwise.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to retrieve information about the highest degree earned by the individual. I want to create three new columns in the dataset with the names like Undergrad_New, Grad_New, and Ph.D_New. If an individual has Undergrad, grad, and Ph.D. degrees, only&amp;nbsp;Ph.D_New column should take value "1" and other two columns should be equal to "0".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please suggest a code for this purpose. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 09:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retrieving-information-about-the-highest-degree-earned/m-p/566815#M159365</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2019-06-18T09:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving information about the highest degree earned</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retrieving-information-about-the-highest-degree-earned/m-p/566838#M159370</link>
      <description>&lt;P&gt;Comments / questions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Is your data already contained in a SAS data set?&amp;nbsp; That's a necessary starting point.&lt;/LI&gt;
&lt;LI&gt;What is the name of the data set?&lt;/LI&gt;
&lt;LI&gt;What are the names of the variables in the data set?&amp;nbsp; Column numbers don't help.&lt;/LI&gt;
&lt;LI&gt;Don't plan on using a dot as part of a variable name.&amp;nbsp; Use PhD_New instead of Ph.D_New&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 18 Jun 2019 12:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retrieving-information-about-the-highest-degree-earned/m-p/566838#M159370</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-06-18T12:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving information about the highest degree earned</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retrieving-information-about-the-highest-degree-earned/m-p/566845#M159375</link>
      <description>&lt;P&gt;I created a dummy dataset and made some assumptions around the starting dataset being used. But I believe the logic below will accomplish the results you need:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WORK.Have;
FORMAT 		ID 8. Name $25. UnderGrad 1. Grad 1. PhD 1.;
INFORMAT	ID 8. Name $25. UnderGrad 1. Grad 1. PhD 1.;
INFILE DATALINES DLM=',' DSD;
INPUT  		ID    Name      UnderGrad    Grad    PhD;
DATALINES;
12345,Adam Ant,1,1,0
23456,Bob Batty,1,0,0
34567,Chuck Cross,1,1,1
45678,David Dunn,1,1,0
56789,Ed Eagers,0,0,0
;


DATA WORK.WANT;
	SET WORK.HAVE;
	FORMAT Undergrad_New	Grad_New	PhD_New 1.;
	     IF PHD=1           THEN DO;  Undergrad_New=0;  Grad_New=0;  PhD_New=1;  END;
	ELSE IF Grad=1 	        THEN DO;  Undergrad_New=0;  Grad_New=1;	 PhD_New=0;  END;
	ELSE IF UnderGrad=1     THEN DO;  Undergrad_New=1;  Grad_New=0;	 PhD_New=0;  END;
	ELSE IF PhD=0 
		AND Grad=0 
		AND UnderGrad=0 THEN DO;  Undergrad_New=0;  Grad_New=0;	 PhD_New=0;  END;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Proc Print&amp;nbsp;Output:&lt;/P&gt;&lt;P&gt;Obs ID Name UnderGrad Grad PhD Undergrad_New Grad_New PhD_New12345&lt;/P&gt;&lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;TD&gt;Adam Ant&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23456&lt;/TD&gt;&lt;TD&gt;Bob Batty&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;34567&lt;/TD&gt;&lt;TD&gt;Chuck Cross&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;45678&lt;/TD&gt;&lt;TD&gt;David Dunn&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;56789&lt;/TD&gt;&lt;TD&gt;Ed Eagers&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 12:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retrieving-information-about-the-highest-degree-earned/m-p/566845#M159375</guid>
      <dc:creator>tsap</dc:creator>
      <dc:date>2019-06-18T12:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving information about the highest degree earned</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retrieving-information-about-the-highest-degree-earned/m-p/567126#M159447</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22122"&gt;@tsap&lt;/a&gt;: Thank you very much. This code works very well.</description>
      <pubDate>Wed, 19 Jun 2019 03:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retrieving-information-about-the-highest-degree-earned/m-p/567126#M159447</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2019-06-19T03:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving information about the highest degree earned</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retrieving-information-about-the-highest-degree-earned/m-p/567219#M159484</link>
      <description>&lt;P&gt;You're welcome&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 11:46:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retrieving-information-about-the-highest-degree-earned/m-p/567219#M159484</guid>
      <dc:creator>tsap</dc:creator>
      <dc:date>2019-06-19T11:46:57Z</dc:date>
    </item>
  </channel>
</rss>

