<?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: is there simpler way to convert char flag to numeric number in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367398#M87457</link>
    <description>&lt;P&gt;Does the data actually have to change? &amp;nbsp;You could just apply a format so that Y=1, N=0 etc.&lt;/P&gt;
&lt;P&gt;However that beng said, why do you need to convert population flag data from Y/N to 1/0? &amp;nbsp;CDISC standards are clear that these variables should be either Y or N, and as they are selection variables (i.e. not analysis variables) then there is no need to have numeric representaion of them. &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2017 14:55:52 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-06-15T14:55:52Z</dc:date>
    <item>
      <title>is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367389#M87453</link>
      <description>&lt;P&gt;I have to convert the below flags to numeric as for "Y" it should be 1 and for "N" it should be 0.&lt;/P&gt;
&lt;P&gt;if saffl="Y" then saffl=1;&lt;BR /&gt; if saffl="N" then saffl=0;&lt;/P&gt;
&lt;P&gt;if ITT="Y" then &lt;SPAN&gt;ITT&lt;/SPAN&gt;=1;&lt;BR /&gt; if &lt;SPAN&gt;ITT&lt;/SPAN&gt;="N" then &lt;SPAN&gt;ITT&lt;/SPAN&gt;=0;&lt;/P&gt;
&lt;P&gt;if PP="Y" then &lt;SPAN&gt;PP&lt;/SPAN&gt;=1;&lt;BR /&gt; if &lt;SPAN&gt;PP&lt;/SPAN&gt;="N" then &lt;SPAN&gt;PP&lt;/SPAN&gt;=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any simpler or effective way in doing the above better?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 14:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367389#M87453</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-06-15T14:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367393#M87456</link>
      <description>&lt;P&gt;1. You cannot change the type of a variable. You'll have to create a new variable do some dropping and renaming.&lt;/P&gt;
&lt;P&gt;2. You should be using if.. else when you create the variable.&lt;/P&gt;
&lt;P&gt;3. Or you can use the boolean reponse: saffl2 = (&lt;SPAN&gt;saffl="Y");&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;4. Depending on what proc you're using, the character Y/N might work anyway as a class variable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this helps...&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 14:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367393#M87456</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-06-15T14:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367398#M87457</link>
      <description>&lt;P&gt;Does the data actually have to change? &amp;nbsp;You could just apply a format so that Y=1, N=0 etc.&lt;/P&gt;
&lt;P&gt;However that beng said, why do you need to convert population flag data from Y/N to 1/0? &amp;nbsp;CDISC standards are clear that these variables should be either Y or N, and as they are selection variables (i.e. not analysis variables) then there is no need to have numeric representaion of them. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 14:55:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367398#M87457</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-15T14:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367621#M87562</link>
      <description>&lt;P&gt;I am using this to update a table which earlier has data for these flags as 1 and 0 but now as Y and N.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if %length(&amp;amp;SAF)=0 %then %let SAFFL=0;&lt;BR /&gt; %else %let SAFFL=%eval(%sysfunc(countc(%cmpres(&amp;amp;SAF),%str( )))+1);&lt;/P&gt;
&lt;P&gt;%if %length(&amp;amp;FAS)=0 %then %let FASFL=0;&lt;BR /&gt; %else %let FASFL=%eval(%sysfunc(countc(%cmpres(&amp;amp;FAS),%str( )))+1);&lt;/P&gt;
&lt;P&gt;%if %length(&amp;amp;PPS)=0 %then %let PPROTFL=0;&lt;BR /&gt; %else %let PPROTFL=%eval(%sysfunc(countc(%cmpres(&amp;amp;PPS),%str( )))+1);&lt;/P&gt;
&lt;P&gt;data inc;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; set adsl;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;%do i = 1 %to &amp;amp;SAFFL;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; %let safvar=%scan(&amp;amp;SAF,&amp;amp;i);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;compl&amp;amp;i=.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;withd&amp;amp;i=.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ong&amp;amp;i=.;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if &amp;amp;safvar = 1 then do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;compl&amp;amp;i=complfl;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if EOTSTT="Discontinued" then withd&amp;amp;i=1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if EOTSTT ne "Discontinued" then ong&amp;amp;i=1;&lt;BR /&gt; end;&lt;BR /&gt; %end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 07:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367621#M87562</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-06-16T07:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367626#M87566</link>
      <description>&lt;P&gt;Sorry, really not seeing why here. &amp;nbsp;The standard is that ther are population flags: SAFFL, FASFL etc. which have the codelist Y or N. &amp;nbsp;You can also have these per period: SAFFL01 SAFFL02 etc. &amp;nbsp;These would also be Y or N. &amp;nbsp;If you need to enumerate over these then simply:&lt;/P&gt;
&lt;PRE&gt;data have;
  usubjid="XXY123"; saffl="Y"; saffl01="Y"; saffl02="Y"; output;
  usubjid="XXY234"; saffl="N"; saffl01="Y"; saffl02="N"; output;
run;
data want;
  set have;
  array flags{*} saffl:;
  do i=1 to dim(flags);
    flags{i}="A";
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;But again, why would you want to be changing these. &amp;nbsp;They are "selection" values, and only used to filter the data - i.e. in where clauses.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 08:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367626#M87566</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-16T08:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367640#M87572</link>
      <description>&lt;P&gt;The problem later in my code is i am using the data below in proc summary and i get error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MPRINT(DISP_SUM_TEST): proc summary data=work._w1;&lt;BR /&gt;MPRINT(DISP_SUM_TEST): ;&lt;BR /&gt;MPRINT(DISP_SUM_TEST): class ACTARM siteid;&lt;BR /&gt;ERROR: Variable ITTFL in list does not match type prescribed for this list.&lt;BR /&gt;ERROR: Variable SAFFL in list does not match type prescribed for this list.&lt;BR /&gt;ERROR: Variable FASFL in list does not match type prescribed for this list.&lt;BR /&gt;MPRINT(DISP_SUM_TEST): var ITTFL SAFFL compl1 withd1 ong1 FASFL PPROTFL;&lt;BR /&gt;ERROR: Variable PPROTFL in list does not match type prescribed for this list.&lt;BR /&gt;MPRINT(DISP_SUM_TEST): output out=work._w2 sum=;&lt;BR /&gt;MPRINT(DISP_SUM_TEST): run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 09:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367640#M87572</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-06-16T09:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367648#M87575</link>
      <description>&lt;P&gt;Summary statistics are for continuous variables (numeric). &amp;nbsp;Flags are for selection purposes. &amp;nbsp;From this code I would suggest you want a frequency count (proc freq) which is the simplest answer:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_freq_sect025.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_freq_sect025.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or a count() in proc sql:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table W2 as
  select ACTARM, 
         SITEID,
         count(case when ITTFL="Y" then 1 else 0 end) as ITTFL,
         count(case when SAFFL="Y" then 1 else 0 end) as SAFFL,
          ...
  from   W1
  group by ACTARM,SITEID;
quit;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 09:54:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367648#M87575</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-16T09:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367678#M87584</link>
      <description>&lt;P&gt;Thanks a lot.&lt;/P&gt;
&lt;P&gt;the original code was like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=w1;&lt;BR /&gt; class arm siteid;&lt;BR /&gt; var %if %upcase(&amp;amp;rand.) ne %then &amp;amp;rand.; &amp;amp;SAF&lt;BR /&gt; %do i = 1 %to &amp;amp;SAFFL;&lt;BR /&gt; compl&amp;amp;i withd&amp;amp;i ong&amp;amp;i&lt;BR /&gt; %end;&lt;BR /&gt; &amp;amp;FAS &amp;amp;PPS;&lt;BR /&gt; output out=w2 sum=;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;I tried using sql as suggested by you but not sure how to deal with&amp;nbsp;&lt;SPAN&gt;%do i = 1 %to &amp;amp;SAFFL; the condition&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 11:34:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367678#M87584</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-06-16T11:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367683#M87586</link>
      <description>&lt;P&gt;Sorry, I really can't help any further. &amp;nbsp;I have no test data or idea of what is required, and I cannot see the code where any of this is being defined. &amp;nbsp;For instance you talk about macro variable&amp;nbsp;&lt;SPAN&gt;&amp;amp;SAFFL; &amp;nbsp;SAFFL in CDISC is SAFety FLag, a Y/N flag as to whether a subject is in the safety population. &amp;nbsp;You cannot therefore do 1 to Y. &amp;nbsp;No macro definitions are given in your code. &amp;nbsp;Proc summary as with means creates summary statistics on continous data. &amp;nbsp;Proc freq gives counts of items. &amp;nbsp;Its almost like SAFFL contains the number of safety populations, but that is not the point of a flag variable, that should be held in different data, so you may have:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;TRTSEQA &amp;nbsp;SAFFL &amp;nbsp;SAFFL01 &amp;nbsp;SAFFL02&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;A-B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Y &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So row 1 is in both periods and the overall population, the second didn't get to period 2 so not in that pop or the overall.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 11:50:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/367683#M87586</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-16T11:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/370450#M88457</link>
      <description>&lt;P&gt;attached is the dummy data.&lt;/P&gt;
&lt;P&gt;program is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%* For each safety pop identifier specified, create flags for completed or withdrawn;&lt;BR /&gt; %do i = 1 %to &amp;amp;SAFFL;&lt;BR /&gt; %let safvar=%scan(&amp;amp;SAF,&amp;amp;i);&lt;BR /&gt; compl&amp;amp;i=.;&lt;BR /&gt; withd&amp;amp;i=.;&lt;BR /&gt; ong&amp;amp;i=.;&lt;BR /&gt; if &amp;amp;safvar = 'Y' then do;&lt;BR /&gt; compl&amp;amp;i=complfl;&lt;BR /&gt; if EOTSTT="Discontinued" then withd&amp;amp;i=1;&lt;BR /&gt; if EOTSTT ne "Discontinued" then ong&amp;amp;i=1;&lt;BR /&gt; end;&lt;BR /&gt; %end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=&amp;amp;work..&amp;amp;ID._w1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;class &amp;amp;armvar siteid;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; var %if %upcase(&amp;amp;rand.) ne %then &amp;amp;rand.; &amp;amp;SAF&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; %do i = 1 %to &amp;amp;SAFFL;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; compl&amp;amp;i withd&amp;amp;i ong&amp;amp;i&lt;BR /&gt;&amp;nbsp; &amp;nbsp; %end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;amp;FAS &amp;amp;PPS;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;output out=&amp;amp;work..&amp;amp;ID._w2 sum=;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;when running will resolve it to&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MPRINT(DISP_SUM_TEST): proc summary data=work._w1;&lt;BR /&gt;MPRINT(DISP_SUM_TEST): class ACTARM siteid;&lt;BR /&gt;ERROR: Variable ITTFL in list does not match type prescribed for this list.&lt;BR /&gt;ERROR: Variable SAFFL in list does not match type prescribed for this list.&lt;BR /&gt;ERROR: Variable FASFL in list does not match type prescribed for this list.&lt;BR /&gt;MPRINT(DISP_SUM_TEST): var ITTFL SAFFL compl1 withd1 ong1 FASFL PPROTFL;&lt;BR /&gt;ERROR: Variable PPROTFL in list does not match type prescribed for this list.&lt;BR /&gt;MPRINT(DISP_SUM_TEST): output out=work._w2 sum=;&lt;BR /&gt;MPRINT(DISP_SUM_TEST): run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 08:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/370450#M88457</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-06-26T08:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/370456#M88458</link>
      <description>&lt;P&gt;I really do think your either overthinking this, or not understanding the models.&lt;/P&gt;
&lt;P&gt;Given that test data, and noting that macro variables have not been described and the data is missing half the information, I arrived at this code:&lt;/P&gt;
&lt;PRE&gt;data work.adll;
  length eotstt $100;
  infile datalines dlm=",";
  input lubjid $ liteid $ ittfl $ laffl $ falfl $ eotstt $;
datalines;
L1710,XX1008,Y,Y,Y,Discontinued
L1718,XX1008,Y,Y,N,Completed
L1708,XX1030,Y,Y,Y,Completed
L1749,CA1029,Y,Y,Y,Completed
L1629,XX1005,Y,Y,N,Completed
L1752,XX1005,Y,Y,Y,Completed
L1771,XX1007,Y,Y,Y,Completed
L1720,XX1015,Y,Y,N,Discontinued
L1769,XX1018,Y,Y,N,Completed
L1747,XX1020,Y,Y,N,Completed
L1719,XX1021,Y,Y,N,Completed
L1766,XX1022,Y,Y,N,Completed
L1737,PL1051,Y,Y,Y,Completed
;
run;

data inter (drop=lubjid ittfl laffl falfl eotstt i);
  set adll;
  array flgs{3} ittfl laffl falfl;
  array flgs_c{3} 8;
  array with{3} 8;
  array nowith{3} 8;
  do i=1 to 3;
    flgs_c{i}=ifn(flgs{i}="Y",1,0);
    with{i}=ifn(flgs{i}="Y" and eotstt="Discontinued",1,0);
    nowith{i}=ifn(flgs{i}="Y" and eotstt ne "Discontinued",1,0);
  end;
run;
    
proc summary data=inter;
  class liteid;
  var _numeric_;
  output out=want sum=;
run;
&lt;/PRE&gt;
&lt;P&gt;To be honest though, you wouldn't need to do all that numeric flag mapping if you just switched to using proc freq - which is what that procedure is used for.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 09:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/370456#M88458</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-26T09:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/370457#M88459</link>
      <description>&lt;P&gt;Thanks for the suggestion.&lt;/P&gt;
&lt;P&gt;i was thinking to use proc freq but was not sure how to handle the macro conditions like the below using proc freq.&lt;/P&gt;
&lt;P&gt;%if %upcase(&amp;amp;rand.) ne %then &amp;amp;rand.; &amp;amp;SAF&lt;BR /&gt; %do i = 1 %to &amp;amp;SAFFL;&lt;BR /&gt; compl&amp;amp;i withd&amp;amp;i ong&amp;amp;i&lt;BR /&gt; %end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 09:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/370457#M88459</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-06-26T09:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/370458#M88460</link>
      <description>&lt;P&gt;There is no need for macro? &amp;nbsp;Model the data correctly, run it through a procedure to get the required output - basic principal of CDISC models.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 09:36:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/370458#M88460</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-26T09:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/376500#M90381</link>
      <description>&lt;P&gt;I use the below step and i get all the counts for each row the same count. can any one let me know where i am wrong&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table mstats as&lt;BR /&gt; select actarm,country,&lt;/P&gt;
&lt;P&gt;count(case when ITTFL="Y" then 1 else 0 end) as rand,&lt;BR /&gt; count(case when SAFFL="Y" then 1 else 0 end) as SAF,&lt;/P&gt;
&lt;P&gt;count(case when FASFL="Y" then 1 else 0 end) as FAS&lt;/P&gt;
&lt;P&gt;from disp_ps&lt;BR /&gt; group by actarm,country;&lt;BR /&gt; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 11:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/376500#M90381</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-07-17T11:45:01Z</dc:date>
    </item>
    <item>
      <title>i am using proc sql case(count statement but is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/376515#M90388</link>
      <description>&lt;P&gt;I use the below step and i get all the counts for each row the same counts for all variables. can any one let me know where i am wrong&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table mstats as&lt;BR /&gt;select actarm,country,&lt;/P&gt;
&lt;P&gt;count(case when ITTFL="Y" then 1 else 0 end) as rand,&lt;BR /&gt;count(case when SAFFL="Y" then 1 else 0 end) as SAF,&lt;/P&gt;
&lt;P&gt;count(case when FASFL="Y" then 1 else 0 end) as FAS&lt;/P&gt;
&lt;P&gt;from disp_ps&lt;BR /&gt;group by actarm,country;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 12:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/376515#M90388</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-07-17T12:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: i am using proc sql case(count statement but is not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/376520#M90389</link>
      <description>&lt;P&gt;Count of 1 or 0 is always 1, so the N is the same no matter what your values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using a SUM instead.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 12:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/376520#M90389</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-17T12:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: is there simpler way to convert char flag to numeric number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/376522#M90387</link>
      <description>&lt;P&gt;You want sum rather than count - count will count records regardless of if they are 1 or 0.&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table mstats as
select actarm,country,
sum(case when ITTFL="Y" then 1 else 0 end) as rand,
sum(case when SAFFL="Y" then 1 else 0 end) as SAF,
sum(case when FASFL="Y" then 1 else 0 end) as FAS
from disp_ps
group by actarm,country;
quit;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jul 2017 13:02:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/is-there-simpler-way-to-convert-char-flag-to-numeric-number/m-p/376522#M90387</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-17T13:02:21Z</dc:date>
    </item>
  </channel>
</rss>

