<?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: INDEX function not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/INDEX-function-not-working/m-p/767796#M243456</link>
    <description>&lt;P&gt;Please disregard my second question I figured it out. Thank you&lt;/P&gt;</description>
    <pubDate>Tue, 14 Sep 2021 20:16:13 GMT</pubDate>
    <dc:creator>billi_billi</dc:creator>
    <dc:date>2021-09-14T20:16:13Z</dc:date>
    <item>
      <title>INDEX function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INDEX-function-not-working/m-p/767599#M243379</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;Just starting coding so maybe this is very basic question. I used INDEX function, but not getting the desired results in the table and also I am not getting any error in the log. Can anyone please help me and tell me what is wrong in my code. My code is below and the data that I used is attached. When I create dataset A2, I do not get any value for variable TRT and ORD.&lt;/P&gt;&lt;P&gt;TIA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*IMPORT THE DATA;&lt;BR /&gt;PROC IMPORT DATAFILE="C:\Users\Data.xls"&lt;BR /&gt;OUT=A&lt;BR /&gt;DBMS=XLS;&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*SELECT RECORDS AND VARIABLES FROM data;&lt;BR /&gt;DATA A1;&lt;BR /&gt;SET A;&lt;BR /&gt;IF SAFFL='Y';&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA A2;&lt;BR /&gt;SET A1;&lt;/P&gt;&lt;P&gt;IF INDEX(TRTP, "ACTIVE DRUG A") &amp;gt;0 THEN DO; TRT = "A"; ORD = 1; END;&lt;BR /&gt;IF INDEX(TRTP, "PLACEBO") &amp;gt;0 THEN DO; TRT = "B"; ORD = 2; END;&lt;/P&gt;&lt;P&gt;KEEP USUBJID TRT ORD;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 01:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INDEX-function-not-working/m-p/767599#M243379</guid>
      <dc:creator>billi_billi</dc:creator>
      <dc:date>2021-09-14T01:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: INDEX function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INDEX-function-not-working/m-p/767601#M243380</link>
      <description>&lt;P&gt;I don't see any values of PLACEBO in that variable, at least as the XLS file is render by this site.&lt;/P&gt;
&lt;P&gt;I see plenty of values of Placebo, but your code is not looking for that string, just the string with all uppercase letters.&lt;/P&gt;
&lt;P&gt;Try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF INDEX(upcase(TRTP), "PLACEBO") &amp;gt;0 THEN DO; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Sep 2021 02:01:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INDEX-function-not-working/m-p/767601#M243380</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-14T02:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: INDEX function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INDEX-function-not-working/m-p/767693#M243429</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;. I got the values in the table now.&lt;/P&gt;&lt;P&gt;One more question, after this step I used PROC SQL to calculate subjects with an event but when I combine and transpose it that number is sorted according to alphabets but I want the number of subjects with event at the top like shown in this picture.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="billi_billi_0-1631625101984.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63558i5921D7D53930ED25/image-size/medium?v=v2&amp;amp;px=400" role="button" title="billi_billi_0-1631625101984.png" alt="billi_billi_0-1631625101984.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;when I first tried my code it was working fine but after that it is not giving me same result not sure why. I would really appreciate your help. Here is my code.&lt;/P&gt;&lt;P&gt;PROC IMPORT DATAFILE="C:\Users\AE.xls"&lt;BR /&gt;OUT=A&lt;BR /&gt;DBMS=XLS;&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*SELECT RECORDS AND VARIABLES FROM ADAE;&lt;BR /&gt;DATA A1;&lt;BR /&gt;SET A;&lt;BR /&gt;IF SAFFL='Y';&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA&amp;nbsp; A2;&lt;BR /&gt;SET A1;&lt;/P&gt;&lt;P&gt;IF INDEX(UPCASE(TRTP), "ACTIVE DRUG A") &amp;gt;0 THEN DO; TRT = "A"; ORD = 1; END;&lt;BR /&gt;IF INDEX(UPCASE(TRTP), "PLACEBO") &amp;gt;0 THEN DO; TRT = "B"; ORD = 2; END;&lt;/P&gt;&lt;P&gt;KEEP USUBJID AEBODSYS AEDECOD AETOXGR TRT ORD;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*CALCULATING 'N'&amp;nbsp; COUNT;&lt;/P&gt;&lt;P&gt;PROC SQL NOPRINT;&lt;BR /&gt;SELECT COUNT (DISTINCT USUBJID) INTO : N1 -:N2 FROM A2&lt;BR /&gt;GROUP BY ORD&lt;BR /&gt;ORDER BY ORD;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%PUT &amp;amp;N1 &amp;amp;N2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*COUNT OF SUBJECTS WITH EVENTS;&lt;BR /&gt;PROC SQL NOPRINT;&lt;BR /&gt;CREATE TABLE ANY AS&lt;BR /&gt;SELECT TRT,COUNT (DISTINCT USUBJID) AS N, "NUMBER OF SUBJECTS WITH AN EVENT" AS AEBODSYS&lt;BR /&gt;LENGTH=200 FROM A2&lt;BR /&gt;GROUP BY TRT;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;CREATE TABLE BODSYS AS&lt;BR /&gt;SELECT TRT,AEBODSYS, COUNT (DISTINCT USUBJID) AS N FROM A2&lt;BR /&gt;GROUP BY TRT, AEBODSYS;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CREATE TABLE DECOD AS&lt;BR /&gt;SELECT TRT,AEBODSYS,AEDECOD, COUNT (DISTINCT USUBJID) AS N FROM A2&lt;BR /&gt;GROUP BY TRT, AEBODSYS,AEDECOD;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATA COMBINE;&lt;BR /&gt;SET ANY BODSYS DECOD;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*TRANSPOSE THE DATA;&lt;BR /&gt;PROC SORT; BY AEBODSYS AEDECOD TRT; RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC TRANSPOSE DATA=COMBINE OUT=COMBINE1;&lt;BR /&gt;ID TRT;&lt;BR /&gt;BY AEBODSYS AEDECOD;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*CALCULATE THE PERCENTAGES;&lt;BR /&gt;DATA FINAL;&lt;BR /&gt;SET COMBINE1;&lt;/P&gt;&lt;P&gt;LENGTH DRUGA PLACEBO $100.;&lt;/P&gt;&lt;P&gt;IF A = . THEN DRUGA = "0 (0)";&lt;BR /&gt;ELSE IF A = &amp;amp;N1 THEN DRUGA = PUT (A, 3.) || "(100%)";&lt;BR /&gt;ELSE DRUGA = PUT (A, 3.) || "(" || PUT(A/ &amp;amp;N1 *100, 4.1) || ")";&lt;/P&gt;&lt;P&gt;IF B = . THEN PLACEBO = "0 (0)";&lt;BR /&gt;ELSE IF B = &amp;amp;N2 THEN PLACEBO = PUT (B, 3.) || "(100%)";&lt;BR /&gt;ELSE PLACEBO= PUT (B, 3.) || "(" || PUT(B/ &amp;amp;N2 *100, 4.1) || ")";&lt;/P&gt;&lt;P&gt;IF AEDECOD EQ " " AND AEBODSYS NE " " THEN AEBODSYS1 = AEBODSYS;&lt;BR /&gt;ELSE AEBODSYS1 = " "||AEDECOD;&lt;/P&gt;&lt;P&gt;DROP A B ;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC REPORT DATA=FINAL HEADLINE HEADSKIP SPLIT='*';&lt;BR /&gt;COLUMN AEBODSYS1 PLACEBO DRUGA;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DEFINE AEBODSYS1/DISPLAY "System Organ Class(%)*Preferred Term (%)";&lt;/P&gt;&lt;P&gt;DEFINE PLACEBO/DISPLAY "PLACEBO* (N=&amp;amp;N2)";&lt;/P&gt;&lt;P&gt;DEFINE DRUGA/DISPLAY "TREATMENT GROUP A* (N=&amp;amp;N1)";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 13:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INDEX-function-not-working/m-p/767693#M243429</guid>
      <dc:creator>billi_billi</dc:creator>
      <dc:date>2021-09-14T13:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: INDEX function not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INDEX-function-not-working/m-p/767796#M243456</link>
      <description>&lt;P&gt;Please disregard my second question I figured it out. Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 20:16:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INDEX-function-not-working/m-p/767796#M243456</guid>
      <dc:creator>billi_billi</dc:creator>
      <dc:date>2021-09-14T20:16:13Z</dc:date>
    </item>
  </channel>
</rss>

