<?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 How to create identifier with each groups in All Things Community</title>
    <link>https://communities.sas.com/t5/All-Things-Community/How-to-create-identifier-with-each-groups/m-p/394142#M2675</link>
    <description>&lt;P&gt;I wanna thank you guys cause i've got so many informations here.&lt;/P&gt;&lt;P&gt;Followings are briefs of my data sheet,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;stnd_y person_id recu_day date sick_sym&amp;nbsp;&lt;/P&gt;&lt;P&gt;2002 100 20020929 02-09-29 A&amp;nbsp;&lt;BR /&gt;2002 100 20020929 02-09-29 B&amp;nbsp;&lt;BR /&gt;2002 100 20020929 02-09-29 D&amp;nbsp;&lt;BR /&gt;2002 100 20020930 02-09-30 B&amp;nbsp;&lt;BR /&gt;2002 100 20020930 02-09-30 E&amp;nbsp;&lt;BR /&gt;2002 100 20021002 02-10-02 X&amp;nbsp;&lt;BR /&gt;2002 100 20021002 02-10-02 W&amp;nbsp;&lt;BR /&gt;2002 101 20020927 02-09-27 S&amp;nbsp;&lt;BR /&gt;2002 101 20020927 02-09-27 O&amp;nbsp;&lt;BR /&gt;2002 101 20020928 02-09-28 C&amp;nbsp;&lt;BR /&gt;2002 102 20021001 02-10-01 F&amp;nbsp;&lt;BR /&gt;2002 103 20021003 02-10-03 G&amp;nbsp;&lt;BR /&gt;2002 104 20021108 02-11-08 H&amp;nbsp;&lt;BR /&gt;2002 104 20021108 02-11-08 A&amp;nbsp;&lt;BR /&gt;2002 104 20021112 02-11-12 B&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, I want to make above things as followings,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;stnd_y person_id recu_day date sick_sym Admission&lt;/P&gt;&lt;P&gt;2002 100 20020929 02-09-29 A 1&lt;BR /&gt;2002 100 20020929 02-09-29 B 1&lt;BR /&gt;2002 100 20020929 02-09-29 D 1&lt;BR /&gt;2002 100 20020930 02-09-30 B 2&lt;BR /&gt;2002 100 20020930 02-09-30 E 2&lt;BR /&gt;2002 100 20021002 02-10-02 X 3&lt;BR /&gt;2002 100 20021002 02-10-02 W 3&lt;BR /&gt;2002 101 20020927 02-09-27 S 1&lt;BR /&gt;2002 101 20020927 02-09-27 O 1&lt;BR /&gt;2002 101 20020928 02-09-28 C 2&lt;BR /&gt;2002 102 20021001 02-10-01 F 1&lt;BR /&gt;2002 103 20021003 02-10-03 G 1&lt;BR /&gt;2002 104 20021108 02-11-08 H 1&lt;BR /&gt;2002 104 20021108 02-11-08 A 1&lt;BR /&gt;2002 104 20021112 02-11-12 B 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I mean, i want to make a variable of admission frequency personally with recu_day and date(this variables mean the date of hospitalization, and each person has several symptoms on every day, so recu_day and date are repeated.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then, I used followings with sas,&lt;/P&gt;&lt;P&gt;proc sort data=old out=new;&lt;BR /&gt;by person_id recu_day;&lt;BR /&gt;data new1;&lt;BR /&gt;set new;&lt;BR /&gt;retain admission 0;&lt;BR /&gt;by person_id recu_day;&lt;BR /&gt;if recu_day^=lag(recu_day) and(or) person_id^=lag(person_id) then&lt;BR /&gt;admission+1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And also,&lt;/P&gt;&lt;P&gt;data new1;&lt;BR /&gt;set new ;&lt;BR /&gt;by person_id recu_day;&lt;BR /&gt;retain adm 0;&lt;BR /&gt;if first.person_id and(or) first.recu_day then admission=admission+1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But, those are not working.&lt;BR /&gt;How can i solve this? Please let me know about this.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obiter dictum,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sort data=a out=a1;&lt;BR /&gt;by person_id recu_fr_dt;&lt;BR /&gt;data a3;&lt;BR /&gt;set a1 ;&lt;BR /&gt;by person_id recu_fr_dt;&lt;BR /&gt;if first.person_id then adm+1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to above codes, the results is following, as i don't mean it.&lt;BR /&gt;&lt;BR /&gt;stnd_y person_id recu_day date sick_sym Admission&lt;/P&gt;&lt;P&gt;2002 100 20020929 02-09-29 A 1&lt;BR /&gt;2002 100 20020929 02-09-29 B 2&lt;BR /&gt;2002 100 20020929 02-09-29 D 3&lt;BR /&gt;2002 100 20020930 02-09-30 B 4&lt;BR /&gt;2002 100 20020930 02-09-30 E 5&lt;BR /&gt;2002 100 20021002 02-10-02 X 6&lt;BR /&gt;2002 100 20021002 02-10-02 W 7&lt;BR /&gt;2002 101 20020927 02-09-27 S 1&lt;BR /&gt;2002 101 20020927 02-09-27 O 2&lt;BR /&gt;2002 101 20020928 02-09-28 C 3&lt;BR /&gt;2002 102 20021001 02-10-01 F 1&lt;BR /&gt;2002 103 20021003 02-10-03 G 1&lt;BR /&gt;2002 104 20021108 02-11-08 H 1&lt;BR /&gt;2002 104 20021108 02-11-08 A 2&lt;BR /&gt;2002 104 20021112 02-11-12 B 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How could i fix it?&lt;/P&gt;&lt;P&gt;Thank you! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Sep 2017 07:08:59 GMT</pubDate>
    <dc:creator>ej_jung</dc:creator>
    <dc:date>2017-09-08T07:08:59Z</dc:date>
    <item>
      <title>How to create identifier with each groups</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-to-create-identifier-with-each-groups/m-p/394142#M2675</link>
      <description>&lt;P&gt;I wanna thank you guys cause i've got so many informations here.&lt;/P&gt;&lt;P&gt;Followings are briefs of my data sheet,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;stnd_y person_id recu_day date sick_sym&amp;nbsp;&lt;/P&gt;&lt;P&gt;2002 100 20020929 02-09-29 A&amp;nbsp;&lt;BR /&gt;2002 100 20020929 02-09-29 B&amp;nbsp;&lt;BR /&gt;2002 100 20020929 02-09-29 D&amp;nbsp;&lt;BR /&gt;2002 100 20020930 02-09-30 B&amp;nbsp;&lt;BR /&gt;2002 100 20020930 02-09-30 E&amp;nbsp;&lt;BR /&gt;2002 100 20021002 02-10-02 X&amp;nbsp;&lt;BR /&gt;2002 100 20021002 02-10-02 W&amp;nbsp;&lt;BR /&gt;2002 101 20020927 02-09-27 S&amp;nbsp;&lt;BR /&gt;2002 101 20020927 02-09-27 O&amp;nbsp;&lt;BR /&gt;2002 101 20020928 02-09-28 C&amp;nbsp;&lt;BR /&gt;2002 102 20021001 02-10-01 F&amp;nbsp;&lt;BR /&gt;2002 103 20021003 02-10-03 G&amp;nbsp;&lt;BR /&gt;2002 104 20021108 02-11-08 H&amp;nbsp;&lt;BR /&gt;2002 104 20021108 02-11-08 A&amp;nbsp;&lt;BR /&gt;2002 104 20021112 02-11-12 B&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, I want to make above things as followings,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;stnd_y person_id recu_day date sick_sym Admission&lt;/P&gt;&lt;P&gt;2002 100 20020929 02-09-29 A 1&lt;BR /&gt;2002 100 20020929 02-09-29 B 1&lt;BR /&gt;2002 100 20020929 02-09-29 D 1&lt;BR /&gt;2002 100 20020930 02-09-30 B 2&lt;BR /&gt;2002 100 20020930 02-09-30 E 2&lt;BR /&gt;2002 100 20021002 02-10-02 X 3&lt;BR /&gt;2002 100 20021002 02-10-02 W 3&lt;BR /&gt;2002 101 20020927 02-09-27 S 1&lt;BR /&gt;2002 101 20020927 02-09-27 O 1&lt;BR /&gt;2002 101 20020928 02-09-28 C 2&lt;BR /&gt;2002 102 20021001 02-10-01 F 1&lt;BR /&gt;2002 103 20021003 02-10-03 G 1&lt;BR /&gt;2002 104 20021108 02-11-08 H 1&lt;BR /&gt;2002 104 20021108 02-11-08 A 1&lt;BR /&gt;2002 104 20021112 02-11-12 B 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I mean, i want to make a variable of admission frequency personally with recu_day and date(this variables mean the date of hospitalization, and each person has several symptoms on every day, so recu_day and date are repeated.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then, I used followings with sas,&lt;/P&gt;&lt;P&gt;proc sort data=old out=new;&lt;BR /&gt;by person_id recu_day;&lt;BR /&gt;data new1;&lt;BR /&gt;set new;&lt;BR /&gt;retain admission 0;&lt;BR /&gt;by person_id recu_day;&lt;BR /&gt;if recu_day^=lag(recu_day) and(or) person_id^=lag(person_id) then&lt;BR /&gt;admission+1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And also,&lt;/P&gt;&lt;P&gt;data new1;&lt;BR /&gt;set new ;&lt;BR /&gt;by person_id recu_day;&lt;BR /&gt;retain adm 0;&lt;BR /&gt;if first.person_id and(or) first.recu_day then admission=admission+1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But, those are not working.&lt;BR /&gt;How can i solve this? Please let me know about this.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obiter dictum,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sort data=a out=a1;&lt;BR /&gt;by person_id recu_fr_dt;&lt;BR /&gt;data a3;&lt;BR /&gt;set a1 ;&lt;BR /&gt;by person_id recu_fr_dt;&lt;BR /&gt;if first.person_id then adm+1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to above codes, the results is following, as i don't mean it.&lt;BR /&gt;&lt;BR /&gt;stnd_y person_id recu_day date sick_sym Admission&lt;/P&gt;&lt;P&gt;2002 100 20020929 02-09-29 A 1&lt;BR /&gt;2002 100 20020929 02-09-29 B 2&lt;BR /&gt;2002 100 20020929 02-09-29 D 3&lt;BR /&gt;2002 100 20020930 02-09-30 B 4&lt;BR /&gt;2002 100 20020930 02-09-30 E 5&lt;BR /&gt;2002 100 20021002 02-10-02 X 6&lt;BR /&gt;2002 100 20021002 02-10-02 W 7&lt;BR /&gt;2002 101 20020927 02-09-27 S 1&lt;BR /&gt;2002 101 20020927 02-09-27 O 2&lt;BR /&gt;2002 101 20020928 02-09-28 C 3&lt;BR /&gt;2002 102 20021001 02-10-01 F 1&lt;BR /&gt;2002 103 20021003 02-10-03 G 1&lt;BR /&gt;2002 104 20021108 02-11-08 H 1&lt;BR /&gt;2002 104 20021108 02-11-08 A 2&lt;BR /&gt;2002 104 20021112 02-11-12 B 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How could i fix it?&lt;/P&gt;&lt;P&gt;Thank you! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 07:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-to-create-identifier-with-each-groups/m-p/394142#M2675</guid>
      <dc:creator>ej_jung</dc:creator>
      <dc:date>2017-09-08T07:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to create identifier with each groups</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-to-create-identifier-with-each-groups/m-p/394164#M2677</link>
      <description>&lt;P&gt;There are some tools worth learning ... they will be invaluable in your future programming. &amp;nbsp;After sorting:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by person_id recu_day;&lt;/P&gt;
&lt;P&gt;if first.person_id then admission=1;&lt;/P&gt;
&lt;P&gt;else if first.recu_day then admission + 1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The BY statement in the DATA step creates temporary variables FIRST. and LAST. for each variable that is in the BY statement. &amp;nbsp;You'll need to both study and practice with them.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 09:29:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-to-create-identifier-with-each-groups/m-p/394164#M2677</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-08T09:29:05Z</dc:date>
    </item>
  </channel>
</rss>

