<?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: unique observations of subject id in longitudinal data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/637336#M78153</link>
    <description>&lt;P&gt;Other ways might be to sort on subject_id, and SET the data using first. or last. criteria.&amp;nbsp; Pretty much the same thing as nodupkey, though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
    <pubDate>Fri, 03 Apr 2020 19:07:45 GMT</pubDate>
    <dc:creator>SteveDenham</dc:creator>
    <dc:date>2020-04-03T19:07:45Z</dc:date>
    <item>
      <title>unique observations of subject id in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/637328#M78151</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;I am very new to sas and am hoping someone can help me. I have a longitudinal survey data set and want to conduct simple descriptive statistics. When I run proc surveyfreq, sas is counting each ID as an observation. Is there an easy way to make sure sas only counts the unique subject IDs?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example this is a snippet of my data :&lt;/P&gt;&lt;P&gt;SUBJECT_ID&amp;nbsp; GENDER&amp;nbsp; AGE&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1007197&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;45&lt;/P&gt;&lt;P&gt;1007197&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;45&lt;/P&gt;&lt;P&gt;1007197&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;45&lt;/P&gt;&lt;P&gt;1007813&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;62&lt;/P&gt;&lt;P&gt;1007813&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;62&lt;/P&gt;&lt;P&gt;1007925&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;53&lt;/P&gt;&lt;P&gt;1007925&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;53&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if I ran a freq on gender it would show total of 7 obs when in reality it should only be a total of 3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would it be correct to do a proc sort with nodupkey to create a separate dataset to conduct only the descriptive stats?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 18:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/637328#M78151</guid>
      <dc:creator>ccp27</dc:creator>
      <dc:date>2020-04-03T18:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: unique observations of subject id in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/637335#M78152</link>
      <description>&lt;P&gt;&lt;EM&gt;"Would it be correct to do a proc sort with nodupkey to create a separate dataset to conduct only the descriptive stats?"-&amp;nbsp;&lt;/EM&gt;I really like this idea.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 18:56:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/637335#M78152</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-04-03T18:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: unique observations of subject id in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/637336#M78153</link>
      <description>&lt;P&gt;Other ways might be to sort on subject_id, and SET the data using first. or last. criteria.&amp;nbsp; Pretty much the same thing as nodupkey, though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 19:07:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/637336#M78153</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2020-04-03T19:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: unique observations of subject id in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/637337#M78154</link>
      <description>&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15363"&gt;@SteveDenham&lt;/a&gt;&amp;nbsp; What a pleasant surprise. I didn't know God of statistics is still active? Have you incarnated again? Believe it or not, Many of stat mates were missing you so badly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 19:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/637337#M78154</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-04-03T19:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: unique observations of subject id in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/638333#M78169</link>
      <description>&lt;P&gt;Lots of great suggestions, here is an SQL approach&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; input 
SUBJECT_ID  GENDER  AGE;  
cards;
1007197           1               45
1007197           1               45
1007197           1               45
1007813           2               62
1007813           2               62
1007925           1               53
1007925           1               53
;
proc sql;
  create table want as
  select distinct SUBJECT_ID, GENDER, AGE, count(SUBJECT_ID) as n_ID 
  from have
  group by SUBJECT_ID
  ;
 quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 14:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/638333#M78169</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2020-04-08T14:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: unique observations of subject id in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/638392#M78170</link>
      <description>&lt;P&gt;SQL is a simple way to do this without modifying the data.&lt;/P&gt;
&lt;P&gt;You can use the DISTINCT keyword inside the COUNT() function. Examples:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select count(distinct subject_id) as nsubjects from have;
select age,count(distinct subject_id) as nsubjects
  from have
  group by age
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2020 16:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/unique-observations-of-subject-id-in-longitudinal-data/m-p/638392#M78170</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-08T16:59:26Z</dc:date>
    </item>
  </channel>
</rss>

