<?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: Transpose character data wide in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675197#M203403</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/78398"&gt;@stancemcgraw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The first part worked, but the array came back in my log as the following error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;74&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;data want;&lt;/P&gt;
&lt;P&gt;475&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;set wide;&lt;/P&gt;
&lt;P&gt;476&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;array _drugs(*) drugs_:;&lt;/P&gt;
&lt;P&gt;WARNING: Defining an array with zero elements.&lt;/P&gt;
&lt;P&gt;477&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;do i=1 to dim(_drugs);&lt;/P&gt;
&lt;P&gt;478&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;_drugs (i) = coalesce(_drugs(i), 0);&lt;/P&gt;
&lt;P&gt;479&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;end;&lt;/P&gt;
&lt;P&gt;480&lt;/P&gt;
&lt;P&gt;481&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;**#calculate total drugs;&lt;/P&gt;
&lt;P&gt;482&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;total_drugs = sum(of drugs_:);&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;---&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;71&lt;/P&gt;
&lt;P&gt;ERROR 71-185: The SUM function call does not have enough arguments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;483&lt;/P&gt;
&lt;P&gt;484&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;
&lt;P&gt;WARNING: The data set WORK.WANT may be incomplete.&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;When this step was stopped there were 0&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;observations and 15 variables.&lt;/P&gt;
&lt;P&gt;WARNING: Data set WORK.WANT was not replaced because this step was stopped.&lt;/P&gt;
&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;real time &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;0.06 seconds&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;cpu time&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;0.04 seconds&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This bit of your code:&lt;/P&gt;
&lt;PRE&gt;476  array _drugs(*) drugs_:;
WARNING: Defining an array with zero elements.&lt;/PRE&gt;
&lt;P&gt;almost certainly means that your data set Wide has no variables whose names start with "drugs_".&lt;/P&gt;
&lt;P&gt;And no existing variables would be the cause of the error using the Sum function to sum the nonexistent.&lt;/P&gt;</description>
    <pubDate>Fri, 07 Aug 2020 09:04:46 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-08-07T09:04:46Z</dc:date>
    <item>
      <title>Transpose character data wide</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675142#M203371</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I'm trying to transpose my long data to wide data, but both variables are character variables. I'd like to count the number of drugs identified per study-ID. Some of the study-IDs also have more than 1 drug found. I also want to create a variable that is the total number of drugs per study-ID after its been transposed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data have:&lt;/P&gt;&lt;P&gt;Study-ID &amp;nbsp; &amp;nbsp; Drugs_found&lt;/P&gt;&lt;P&gt;ID-1-RMC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Opioid&lt;/P&gt;&lt;P&gt;ID-2-RMC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; None&lt;/P&gt;&lt;P&gt;ID-3-RMC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Benzo&lt;/P&gt;&lt;P&gt;ID-4-RMC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cocaine&lt;/P&gt;&lt;P&gt;ID-4-RMC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Opioid&lt;/P&gt;&lt;P&gt;ID-5-RMC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Meth&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data want:&lt;/P&gt;&lt;P&gt;Study-ID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OPIOIDS &amp;nbsp; &amp;nbsp;METH &amp;nbsp; &amp;nbsp;NONE &amp;nbsp; &amp;nbsp;COCAINE &amp;nbsp; &amp;nbsp;BENZOS &amp;nbsp; &amp;nbsp; &amp;nbsp;Total_drugs&lt;/P&gt;&lt;P&gt;ID-1-RMC &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; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;ID-2-RMC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;ID-3-RMC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;ID-4-RMC &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; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &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;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;ID-5-RMC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &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;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 21:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675142#M203371</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2020-08-06T21:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose character data wide</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675153#M203377</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data long ;
set have;

count = 1;
run;

proc transpose data=long out=wide prefix=DRUG_;
by studyID;
ID Drugs_Found;
IDLABEL drugs_found;
var Count;
run;

data want;
set wide;
array _drugs(*) drugs_:;
do i=1 to dim(_drugs);
    _drugs (i) = coalesce(_drugs(i), 0);
end;

#calculate total drugs;
total_drugs = sum(of drugs_:);

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PROC TRANSPOSE works well. If all you need is the output though, PROC TABULATE or PROC REPORT maybe a better option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 22:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675153#M203377</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-06T22:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose character data wide</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675154#M203378</link>
      <description>&lt;P&gt;It is best to provide data in form of a data step.&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;data have;
  input StudyID $    Drugs_found $;
datalines;
ID-1-RMC        Opioid
ID-2-RMC         None
ID-3-RMC         Benzo
ID-4-RMC        Cocaine
ID-4-RMC        Opioid
ID-5-RMC         Meth
;

proc summary data=have nway completetypes;
   class StudyID drugs_found ;
   output out=work.summary (drop=_type_ rename=(_freq_=count))
   ;
run;

proc transpose data=work.summary
   out=work.trans (drop=_name_);
   by StudyID;
   var count;
   id drugs_found;
run;

 &lt;/PRE&gt;
&lt;P&gt;The summary step COMPLETETYPES makes sure that all of the combinations of the class variables that appear are in the output data. The NWAY option only gives us the summaries of both class variables, other wise there would also be summaries overall and for each of the variables only, which is useful sometimes.&lt;/P&gt;
&lt;P&gt;Without any VAR variable all we get is a _freq_ variable that I renamed count just for fun.&lt;/P&gt;
&lt;P&gt;The default behavior of Proc Summary will sort by the values of the class variables so the output is sorted by StudyId and ready for Proc transpose.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 22:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675154#M203378</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-06T22:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose character data wide</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675156#M203380</link>
      <description>&lt;P&gt;Thanks Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; The first part worked, but the array came back in my log as the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;74&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;data want;&lt;/P&gt;&lt;P&gt;475&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;set wide;&lt;/P&gt;&lt;P&gt;476&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;array _drugs(*) drugs_:;&lt;/P&gt;&lt;P&gt;WARNING: Defining an array with zero elements.&lt;/P&gt;&lt;P&gt;477&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;do i=1 to dim(_drugs);&lt;/P&gt;&lt;P&gt;478&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;_drugs (i) = coalesce(_drugs(i), 0);&lt;/P&gt;&lt;P&gt;479&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;end;&lt;/P&gt;&lt;P&gt;480&lt;/P&gt;&lt;P&gt;481&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;**#calculate total drugs;&lt;/P&gt;&lt;P&gt;482&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;total_drugs = sum(of drugs_:);&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;---&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;71&lt;/P&gt;&lt;P&gt;ERROR 71-185: The SUM function call does not have enough arguments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;483&lt;/P&gt;&lt;P&gt;484&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;WARNING: The data set WORK.WANT may be incomplete.&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;When this step was stopped there were 0&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;observations and 15 variables.&lt;/P&gt;&lt;P&gt;WARNING: Data set WORK.WANT was not replaced because this step was stopped.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;real time &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;0.06 seconds&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;cpu time&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;0.04 seconds&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 22:16:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675156#M203380</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2020-08-06T22:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose character data wide</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675157#M203381</link>
      <description>Show the full code. The issues isn't with this step it's with a preceding step.</description>
      <pubDate>Thu, 06 Aug 2020 22:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675157#M203381</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-06T22:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose character data wide</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675197#M203403</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/78398"&gt;@stancemcgraw&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; The first part worked, but the array came back in my log as the following error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;74&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;data want;&lt;/P&gt;
&lt;P&gt;475&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;set wide;&lt;/P&gt;
&lt;P&gt;476&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;array _drugs(*) drugs_:;&lt;/P&gt;
&lt;P&gt;WARNING: Defining an array with zero elements.&lt;/P&gt;
&lt;P&gt;477&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;do i=1 to dim(_drugs);&lt;/P&gt;
&lt;P&gt;478&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;_drugs (i) = coalesce(_drugs(i), 0);&lt;/P&gt;
&lt;P&gt;479&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;end;&lt;/P&gt;
&lt;P&gt;480&lt;/P&gt;
&lt;P&gt;481&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;**#calculate total drugs;&lt;/P&gt;
&lt;P&gt;482&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;total_drugs = sum(of drugs_:);&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;---&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;71&lt;/P&gt;
&lt;P&gt;ERROR 71-185: The SUM function call does not have enough arguments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;483&lt;/P&gt;
&lt;P&gt;484&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;
&lt;P&gt;WARNING: The data set WORK.WANT may be incomplete.&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;When this step was stopped there were 0&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;observations and 15 variables.&lt;/P&gt;
&lt;P&gt;WARNING: Data set WORK.WANT was not replaced because this step was stopped.&lt;/P&gt;
&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;real time &lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;0.06 seconds&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;cpu time&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;0.04 seconds&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This bit of your code:&lt;/P&gt;
&lt;PRE&gt;476  array _drugs(*) drugs_:;
WARNING: Defining an array with zero elements.&lt;/PRE&gt;
&lt;P&gt;almost certainly means that your data set Wide has no variables whose names start with "drugs_".&lt;/P&gt;
&lt;P&gt;And no existing variables would be the cause of the error using the Sum function to sum the nonexistent.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 09:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675197#M203403</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-07T09:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose character data wide</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675257#M203420</link>
      <description>This worked too, thank you!</description>
      <pubDate>Fri, 07 Aug 2020 15:34:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675257#M203420</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2020-08-07T15:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Transpose character data wide</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675497#M203553</link>
      <description>So I am trying to this today with another character variable, comorbidities, and it's giving me the following error when I run the proc transpose step&lt;BR /&gt;(proc sort data=long; by mitchid; run;&lt;BR /&gt;proc transpose data=long out=wide prefix=comorbid_;&lt;BR /&gt;by mitchID;&lt;BR /&gt;ID comorbidities;&lt;BR /&gt;IDLABEL comorbidities;&lt;BR /&gt;var Count;&lt;BR /&gt;run;)&lt;BR /&gt;"ERROR: The ID value "comorbid_CVA" occurs twice in the same BY group.&lt;BR /&gt;ERROR: The ID value "comorbid_DEMENTIA" occurs twice in the same BY group.&lt;BR /&gt;ERROR: The ID value "comorbid_DEPENDENT_HLTH" occurs twice in the same BY group.&lt;BR /&gt;ERROR: The ID value "comorbid_HYPERTENSION" occurs twice in the same BY group.&lt;BR /&gt;ERROR: The ID value "comorbid_CHEMOTHERAPY" occurs twice in the same BY group.&lt;BR /&gt;NOTE: The above message was for the following BY group:&lt;BR /&gt;MITCHID=&lt;BR /&gt;WARNING: 1647 observations omitted due to missing ID values.&lt;BR /&gt;WARNING: 1 BY groups omitted due to earlier errors.&lt;BR /&gt;</description>
      <pubDate>Sun, 09 Aug 2020 19:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transpose-character-data-wide/m-p/675497#M203553</guid>
      <dc:creator>stancemcgraw</dc:creator>
      <dc:date>2020-08-09T19:17:43Z</dc:date>
    </item>
  </channel>
</rss>

