<?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 repeat a symput function to multiple observations in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466145#M14531</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to require 6 variables (in a wide data format) to be equal to a certain value, pending on a variable's "values". TO make it simple, I created only 2 variables here as an example. Depend on the value in each row of variable "mon", I want to use that value for the suffix "X" of the variable "monthX", and require that "monthX" to be equal "c". Here is my code, and it seem like it only works for the first row. How do I make this work for multiple rows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;input id mon $2. month1 $2. month2 $2. ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;datalines;&lt;BR /&gt;1 2 c c&lt;BR /&gt;2 1 c n&lt;BR /&gt;3 1 n n&lt;BR /&gt;4 2 c n&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=a; run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%macro test(dataset);&lt;BR /&gt;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;set &amp;amp;dataset. nobs=x;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx('max',x);&lt;BR /&gt;run;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;data b;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;set &amp;amp;dataset.;&lt;BR /&gt;%do i=1 %to &amp;amp;max.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;call symputx('mon1',"month"||compress(mon));&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if &amp;amp;mon1. in('c')&amp;nbsp; then enroll=1;&lt;BR /&gt;%end;&lt;BR /&gt;%mend test;&lt;BR /&gt;%test(a);&lt;BR /&gt;proc print data=b; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here is the output for the dataset b. The "enroll" variable in row 2, and 4 supposed to be 1 as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;Obs id mon month1 month2 enroll1234 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 30 May 2018 17:36:36 GMT</pubDate>
    <dc:creator>TLSAS</dc:creator>
    <dc:date>2018-05-30T17:36:36Z</dc:date>
    <item>
      <title>How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466145#M14531</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to require 6 variables (in a wide data format) to be equal to a certain value, pending on a variable's "values". TO make it simple, I created only 2 variables here as an example. Depend on the value in each row of variable "mon", I want to use that value for the suffix "X" of the variable "monthX", and require that "monthX" to be equal "c". Here is my code, and it seem like it only works for the first row. How do I make this work for multiple rows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;input id mon $2. month1 $2. month2 $2. ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;datalines;&lt;BR /&gt;1 2 c c&lt;BR /&gt;2 1 c n&lt;BR /&gt;3 1 n n&lt;BR /&gt;4 2 c n&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc print data=a; run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%macro test(dataset);&lt;BR /&gt;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;set &amp;amp;dataset. nobs=x;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx('max',x);&lt;BR /&gt;run;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;data b;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;set &amp;amp;dataset.;&lt;BR /&gt;%do i=1 %to &amp;amp;max.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;call symputx('mon1',"month"||compress(mon));&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if &amp;amp;mon1. in('c')&amp;nbsp; then enroll=1;&lt;BR /&gt;%end;&lt;BR /&gt;%mend test;&lt;BR /&gt;%test(a);&lt;BR /&gt;proc print data=b; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here is the output for the dataset b. The "enroll" variable in row 2, and 4 supposed to be 1 as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;Obs id mon month1 month2 enroll1234 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;n&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 30 May 2018 17:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466145#M14531</guid>
      <dc:creator>TLSAS</dc:creator>
      <dc:date>2018-05-30T17:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466149#M14532</link>
      <description>&lt;P&gt;I'm afraid you do not need a macro wrapper nor&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;set &amp;amp;dataset. nobs=x;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx('max',x);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%do i=1 %to &amp;amp;max.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;call symputx('mon1',"month"||compress(mon));&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if &amp;amp;mon1. in('c')&amp;nbsp; then enroll=1;&lt;BR /&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Macro language in full is completely unnecessary and won't work well for your need.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can you tell us what you want in your Dataset b(your output dataset)? Please&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 17:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466149#M14532</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-30T17:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466153#M14533</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212806"&gt;@TLSAS&lt;/a&gt;&amp;nbsp;Are you after this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
    input id mon $2. month1 $2. month2 $2. ;
    datalines;
1 2 c c
2 1 c n
3 1 n n
4 2 c n
;
run;


data b;
set a;
array t(*) month:;
do _n_=1 to dim(t);
if t(_n_)='c' then enroll=1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 May 2018 17:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466153#M14533</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-30T17:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466155#M14534</link>
      <description>&lt;P&gt;Hi Novinosrin,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the macro because I always got the error message with the %do statement (see bellow).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For output dataset b, I want to create a binary variable that equal to 1 whenever the variable "mon" has the value that equal to the suffix of the variable "month1-month2".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that clear to you?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;ERROR: The %DO statement is not valid in open code.&lt;BR /&gt;240&lt;BR /&gt;241&amp;nbsp; %do i=1 %to &amp;amp;max.;&lt;BR /&gt;242&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx('mon1',"month"||compress(mon));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ----&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 180&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 17:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466155#M14534</guid>
      <dc:creator>TLSAS</dc:creator>
      <dc:date>2018-05-30T17:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466156#M14535</link>
      <description>&lt;P&gt;Thanks for the code, but this is not what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a binary variable that equal to 1 whenever the variable "mon" has the value that equal to the suffix of one of the variables "month1-month2".&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 18:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466156#M14535</guid>
      <dc:creator>TLSAS</dc:creator>
      <dc:date>2018-05-30T18:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466161#M14536</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212806"&gt;@TLSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Thanks for the code, but this is not what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a binary variable that equal to 1 whenever the &lt;STRONG&gt;variable "mon" has the value that equal to the suffix of one of the variables "month1-month2".&lt;/STRONG&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;With that all 4 in your sample does match&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
    input id mon $2. month1 $2. month2 $2. ;
    datalines;
1 2 c c
2 1 c n
3 1 n n
4 2 c n
;
run;
data b;
set a;
array t(*) month:;
do _n_=1 to dim(t);
if mon=char(vname(t(_n_)),length(vname(t(_n_)))) then enroll=1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 18:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466161#M14536</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-30T18:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466184#M14537</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much! This works very well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I forgot to mention that because I wanted the enroll=1 whenever the "mon" value is aqual to the suffix of one of the variable "month1=month2" PLUS the "monthX" variable and Month(X+1) variable have to be equal to "c".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, if mon=1&amp;nbsp; &amp;amp; month1='c' &amp;amp; month2='c' then enroll=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I modified your code and it did not work (see the error). Could you please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data a;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input id mon $2. month1 $2. month2 $2. ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;BR /&gt;1 2 c c&lt;BR /&gt;2 1 c c&lt;BR /&gt;3 1 n n&lt;BR /&gt;4 2 c n&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data b;&lt;BR /&gt;set a;&lt;BR /&gt;array t(*) month:;&lt;BR /&gt;do _n_=1 to dim(t);&lt;BR /&gt;if mon=char(vname(t(_n_)),length(vname(t(_n_)))) and t(_n_) ='c' and t(_n_+1) ='c' then enroll2=1;&lt;BR /&gt;end;&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;ERROR: Array subscript out of range at line 409 column 70.&lt;BR /&gt;id=1 mon=2 month1=c month2=c enroll2=. _ERROR_=1 _N_=2&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: There were 1 observations read from the data set WORK.A.&lt;BR /&gt;WARNING: The data set WORK.B may be incomplete.&amp;nbsp; When this step was stopped there were 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; observations and 5 variables.&lt;BR /&gt;WARNING: Data set WORK.B was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 18:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466184#M14537</guid>
      <dc:creator>TLSAS</dc:creator>
      <dc:date>2018-05-30T18:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466186#M14538</link>
      <description>&lt;P&gt;Do you mean both month1 and month2 will have to be C or any one of the two&amp;nbsp; can be C?&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 18:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466186#M14538</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-30T18:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466189#M14539</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an example dataset, so it is much more simple than my dataset. I have maybe 50 variables of month1-month70 that play the same role as "month1-month2" here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I want whenever the "mon" variable is equal to the suffix of a monthX variable, that monthX plus the month follow monthX (i.e&lt;/P&gt;&lt;P&gt;MOnthX+1) have to both be equal to "c" as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 18:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466189#M14539</guid>
      <dc:creator>TLSAS</dc:creator>
      <dc:date>2018-05-30T18:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466200#M14540</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212806"&gt;@TLSAS&lt;/a&gt;&amp;nbsp;I certainly do understand your real data will have month vars&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;&lt;SPAN&gt;"mon" variable is equal to the suffix of a monthX variable ---if this condition is true&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 2 c c&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;2 = month2&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;so monthx=month2&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;month2=c can't be compared with month3=c. this case happens dealing with the last variable in the list. What's your take on that?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Therefore in your sample&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;1 2 c c&lt;BR /&gt;2 1 c n&lt;BR /&gt;3 1 n n&lt;BR /&gt;4 2 c n&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;no records will satisfy monthx= monthx+1 after establishing&amp;nbsp;&amp;nbsp;"mon" variable is equal to the suffix of a monthX variable -&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 19:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466200#M14540</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-30T19:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466214#M14541</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is correct. The dataset has no record that satisfies the requirement. So I changed one row in the input dataset .&lt;/P&gt;&lt;P&gt;However, my modified code is not working because there is always a last variable that is out of the range specified in the array statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion what should I do?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input id mon $2. month1 $2. month2 $2. ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;BR /&gt;1 2 c c&lt;BR /&gt;2 1 c c&lt;BR /&gt;3 1 n n&lt;BR /&gt;4 2 c n&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 19:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466214#M14541</guid>
      <dc:creator>TLSAS</dc:creator>
      <dc:date>2018-05-30T19:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466216#M14543</link>
      <description>&lt;P&gt;Please test the below&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
    input id mon $2. month1 $2. month2 $2. ;
    datalines;
1 2 c c
2 1 c c
3 1 n n
4 2 c n
;
run;
data b;
set a;
array t(*) month:;
do _n_=1 to dim(t)-1;
if mon=char(vname(t(_n_)),length(vname(t(_n_)))) and t(_n_)='c' and t(_n_+1)='c' then enroll=1;
end;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and let me know&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 19:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466216#M14543</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-30T19:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466217#M14544</link>
      <description>This works perfectly! Thanks so much!&lt;BR /&gt;&lt;BR /&gt;Best,</description>
      <pubDate>Wed, 30 May 2018 19:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466217#M14544</guid>
      <dc:creator>TLSAS</dc:creator>
      <dc:date>2018-05-30T19:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466218#M14545</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212806"&gt;@TLSAS&lt;/a&gt;&amp;nbsp;Always welcome and feel free. Take care&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 19:50:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466218#M14545</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-30T19:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466443#M14565</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212806"&gt;@TLSAS&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm glad you found some useful info! If one of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;'s replies was the exact solution to your problem, can you "Accept it as a solution"? Or if one was particularly helpful, feel free to "Like" it. This will help other community members who may run into the same issue know what worked.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Anna&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 13:42:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466443#M14565</guid>
      <dc:creator>AnnaBrown</dc:creator>
      <dc:date>2018-05-31T13:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466451#M14566</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/33307"&gt;@AnnaBrown&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I marked the solution!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 13:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466451#M14566</guid>
      <dc:creator>TLSAS</dc:creator>
      <dc:date>2018-05-31T13:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466653#M14572</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expand the codes yesterday into the dataset with multiple "month" variables, when months suffix is more than 10 (i.e the suffix is 2 numbers) then the code is not correct anymore. See the code below, its not working. Could you help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input id mon $2. month11 $2. month12 $2. month13 $2. month14 $2. month15 $2. month16 $2.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;BR /&gt;1 12 c c c c c n&lt;BR /&gt;2 10 c c n n c n&lt;BR /&gt;3 13 n n c c n n&lt;BR /&gt;4 12 c n c n c c&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data b;&lt;BR /&gt;set a;&lt;BR /&gt;array t(*) month:;&lt;BR /&gt;do _n_=1 to dim(t)-1;&lt;BR /&gt;if mon=char(vname(t(_n_)),length(vname(t(_n_)))) and t(_n_)='c' and t(_n_+1)='c' then enroll=1;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 22:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466653#M14572</guid>
      <dc:creator>TLSAS</dc:creator>
      <dc:date>2018-05-31T22:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466655#M14573</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212806"&gt;@TLSAS&lt;/a&gt;&amp;nbsp; Aah ok, ofcourse won;t work for the reason&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;length(vname(t(_n_)) finds the last one.. Brb soon&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 22:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466655#M14573</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-31T22:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466659#M14574</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212806"&gt;@TLSAS&lt;/a&gt;&amp;nbsp;Please test the below and let me know. I am here at my college lab for two more hours to&amp;nbsp; make any further changes if needed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
    input id mon $2. month11 $2. month12 $2. month13 $2. month14 $2. month15 $2. month16 $2.;
    datalines;
1 12 c c c c c n
2 10 c c n n c n
3 13 n n c c n n
4 12 c n c n c c
;
run;

data b;
set a;
array t(*) month:;
do _n_=1 to dim(t)-1;
if mon=substr(vname(t(_n_)),anydigit(vname(t(_n_))))  and t(_n_)='c' and t(_n_+1)='c' then enroll=1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 May 2018 22:34:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466659#M14574</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-31T22:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to repeat a symput function to multiple observations</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466717#M14576</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;! This works well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to use substr but it didn't work, and you always know what works. Amazing. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 03:23:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-repeat-a-symput-function-to-multiple-observations/m-p/466717#M14576</guid>
      <dc:creator>TLSAS</dc:creator>
      <dc:date>2018-06-01T03:23:15Z</dc:date>
    </item>
  </channel>
</rss>

