<?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 Identifying single or multiple observations per row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-single-or-multiple-observations-per-row/m-p/564726#M158430</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set, Have, where Manager1,&amp;nbsp;Manager2, and&amp;nbsp;Manager3 show gender of these three managers, for unique IDs. '0' stands for a Male and '1' for a Female manager. Missing observations are displayed as '.'.&lt;/P&gt;&lt;P&gt;I want another data set with two new columns of Dummy Variables. One column should take value '0' when on a particular date, more than one managers are serving (multiple observations in a row). The value should be '1' if only one/single manager (one observation per row) is there on a particular date.&lt;/P&gt;&lt;P&gt;Second column should specify the gender of that single manager on a particular date. So if on a date, only one manager's observation is available, the new column should take value '1', if the manager is a Female, or '0' if Male. If multiple observtions are there per row, then this new column should take missing value i.e. '.'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see below a sample of "Have" and "Want" data sets.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
	Date_Month : mmddyy10.
	Manager1
	Manager2
	Manager3 ;
format Date_Month mmddyy10. ;
datalines;
AB00046,11-30-2016,.,.,.
AB00046,12-31-2016,0,.,.
AB00046,01-31-2017,0,0,1
AB00046,02-28-2017,.,0,.
AB00048,11-30-2016,1,.,0
AB00048,12-31-2016,1,.,0
AB00048,01-31-2017,1,0,0
AB00048,02-28-2017,1,0,.
AB00050,11-30-2016,.,.,1
AB00050,12-31-2016,.,0,1
AB00050,01-31-2017,1,0,1
AB00050,02-28-2017,.,0,.
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Want;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
	Date_Month : mmddyy10.
	Manager1
	Manager2
	Manager3
	Single_dummy
	Gender_dummy;
format Date_Month mmddyy10. ;
datalines;
AB00046,11-30-2016,.,.,.,.,.
AB00046,12-31-2016,0,.,.,1,0
AB00046,01-31-2017,0,0,1,0,.
AB00046,02-28-2017,.,0,.,1,0
AB00048,11-30-2016,1,.,0,0,.
AB00048,12-31-2016,1,.,0,0,.
AB00048,01-31-2017,1,0,0,0,.
AB00048,02-28-2017,1,0,.,0,.
AB00050,11-30-2016,.,.,1,1,1
AB00050,12-31-2016,.,0,1,0,.
AB00050,01-31-2017,1,0,1,0,.
AB00050,02-28-2017,.,0,.,1,0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Kindly guide which code will fulfill this purpose. Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 09 Jun 2019 03:07:29 GMT</pubDate>
    <dc:creator>Saba1</dc:creator>
    <dc:date>2019-06-09T03:07:29Z</dc:date>
    <item>
      <title>Identifying single or multiple observations per row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-single-or-multiple-observations-per-row/m-p/564726#M158430</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set, Have, where Manager1,&amp;nbsp;Manager2, and&amp;nbsp;Manager3 show gender of these three managers, for unique IDs. '0' stands for a Male and '1' for a Female manager. Missing observations are displayed as '.'.&lt;/P&gt;&lt;P&gt;I want another data set with two new columns of Dummy Variables. One column should take value '0' when on a particular date, more than one managers are serving (multiple observations in a row). The value should be '1' if only one/single manager (one observation per row) is there on a particular date.&lt;/P&gt;&lt;P&gt;Second column should specify the gender of that single manager on a particular date. So if on a date, only one manager's observation is available, the new column should take value '1', if the manager is a Female, or '0' if Male. If multiple observtions are there per row, then this new column should take missing value i.e. '.'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see below a sample of "Have" and "Want" data sets.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
	Date_Month : mmddyy10.
	Manager1
	Manager2
	Manager3 ;
format Date_Month mmddyy10. ;
datalines;
AB00046,11-30-2016,.,.,.
AB00046,12-31-2016,0,.,.
AB00046,01-31-2017,0,0,1
AB00046,02-28-2017,.,0,.
AB00048,11-30-2016,1,.,0
AB00048,12-31-2016,1,.,0
AB00048,01-31-2017,1,0,0
AB00048,02-28-2017,1,0,.
AB00050,11-30-2016,.,.,1
AB00050,12-31-2016,.,0,1
AB00050,01-31-2017,1,0,1
AB00050,02-28-2017,.,0,.
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Want;
infile datalines
dlm=","
missover
DSD;
input ID : $10.
	Date_Month : mmddyy10.
	Manager1
	Manager2
	Manager3
	Single_dummy
	Gender_dummy;
format Date_Month mmddyy10. ;
datalines;
AB00046,11-30-2016,.,.,.,.,.
AB00046,12-31-2016,0,.,.,1,0
AB00046,01-31-2017,0,0,1,0,.
AB00046,02-28-2017,.,0,.,1,0
AB00048,11-30-2016,1,.,0,0,.
AB00048,12-31-2016,1,.,0,0,.
AB00048,01-31-2017,1,0,0,0,.
AB00048,02-28-2017,1,0,.,0,.
AB00050,11-30-2016,.,.,1,1,1
AB00050,12-31-2016,.,0,1,0,.
AB00050,01-31-2017,1,0,1,0,.
AB00050,02-28-2017,.,0,.,1,0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Kindly guide which code will fulfill this purpose. Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jun 2019 03:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-single-or-multiple-observations-per-row/m-p/564726#M158430</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2019-06-09T03:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying single or multiple observations per row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-single-or-multiple-observations-per-row/m-p/564728#M158432</link>
      <description>&lt;P&gt;Function n() counts the non missing values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array m{*} manager:;
if n(of m{*}) &amp;gt; 0 then Single_dummy = n(of m{*}) = 1;
if n(of m{*}) = 1 then Gender_dummy = max(of m{*});
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Jun 2019 03:48:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-single-or-multiple-observations-per-row/m-p/564728#M158432</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-06-09T03:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying single or multiple observations per row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-single-or-multiple-observations-per-row/m-p/565441#M158754</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;: Thank you very much. This code works very well.</description>
      <pubDate>Tue, 11 Jun 2019 23:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-single-or-multiple-observations-per-row/m-p/565441#M158754</guid>
      <dc:creator>Saba1</dc:creator>
      <dc:date>2019-06-11T23:37:30Z</dc:date>
    </item>
  </channel>
</rss>

