<?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: Creating New Variables with %Do Loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144732#M28900</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Macro is a pre-processor that generates SAS code.&amp;nbsp; That is why you need to use %IF so that you can conditionally generate the code you want.&lt;/P&gt;&lt;P&gt;I am not sure why %IF/%THEN is any more "clumsy" than IF/THEN, they basically are the same type of construct, but they are operating in two different languages.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to generate code from data then it is probably easier to use a regular program instead of macro code.&amp;nbsp; You could generate code to a macro variable and reference it where you want it used. Or you could use CALL EXECUTE().&amp;nbsp; Or write the code to a file and %INCLUDE the file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new_vars ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length name $32 type $4 length 8 ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;X1 num 8&lt;/P&gt;&lt;P&gt;X2 char 3&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt; select catx(' ',name,case when type='char' then '$' else ' ' end,length)&lt;/P&gt;&lt;P&gt; into :lengths separated by ' '&lt;/P&gt;&lt;P&gt; from new_vars;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt; length &amp;amp;lengths ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Sep 2014 03:21:36 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2014-09-15T03:21:36Z</dc:date>
    <item>
      <title>Creating New Variables with %Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144731#M28899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Say I want to create 100 new variables (x1, x2,,, x100) with %do %to loop, and x1 might be char and x2 might be numeric and so on, the following sample code strangely does not allow me to create x1 and x2 with different format: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro format(); &lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;%do i=1 %to 2;&lt;/P&gt;&lt;P&gt;if &amp;amp;i.=1 then x&amp;amp;i.=1;&lt;/P&gt;&lt;P&gt;if &amp;amp;i.=2 then x&amp;amp;i.="two";&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%format();&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to change the code a little bit to get what I want:&lt;/P&gt;&lt;P&gt;%macro format1();&lt;/P&gt;&lt;P&gt;data test1;&lt;/P&gt;&lt;P&gt;%do i=1 %to 2;&lt;/P&gt;&lt;P&gt;%if &amp;amp;i.=1 %then %do; x&amp;amp;i.=1; %end;&lt;/P&gt;&lt;P&gt;%if &amp;amp;i.=2 %then %do; x&amp;amp;i.="two"; %end;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%format1();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so the questions are, 1) what is the reason behind the wierd behavior, and 2) is there is a way to do what I want, using only "if then" instead of "%if %then", as "%if %then" is so clumsy and I cannot really use it in more compleecated coding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 02:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144731#M28899</guid>
      <dc:creator>armor</dc:creator>
      <dc:date>2014-09-15T02:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating New Variables with %Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144732#M28900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Macro is a pre-processor that generates SAS code.&amp;nbsp; That is why you need to use %IF so that you can conditionally generate the code you want.&lt;/P&gt;&lt;P&gt;I am not sure why %IF/%THEN is any more "clumsy" than IF/THEN, they basically are the same type of construct, but they are operating in two different languages.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to generate code from data then it is probably easier to use a regular program instead of macro code.&amp;nbsp; You could generate code to a macro variable and reference it where you want it used. Or you could use CALL EXECUTE().&amp;nbsp; Or write the code to a file and %INCLUDE the file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new_vars ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length name $32 type $4 length 8 ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;X1 num 8&lt;/P&gt;&lt;P&gt;X2 char 3&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt; select catx(' ',name,case when type='char' then '$' else ' ' end,length)&lt;/P&gt;&lt;P&gt; into :lengths separated by ' '&lt;/P&gt;&lt;P&gt; from new_vars;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt; length &amp;amp;lengths ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 03:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144732#M28900</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-09-15T03:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating New Variables with %Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144733#M28901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom. thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My point here is that I have been using %do loop to create 100 new variables (x1 to x100) and everything worked perfectly fine for me as long as x1, x2, ...x100 are of the same format (either all char or all numeric).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but strange thing happened when x1, x2... x100 are of different formats, i.e. mixed of char and num. See the following 3 macros - the first 2 macros give you the corect outcomes, and the third macro gives you undesired results:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro format_num(); &lt;/P&gt;&lt;P&gt;data test_num;&lt;/P&gt;&lt;P&gt;%do i=1 %to 2;&lt;/P&gt;&lt;P&gt;if &amp;amp;i.=1 then x&amp;amp;i.=1;&lt;/P&gt;&lt;P&gt;if &amp;amp;i.=2 then x&amp;amp;i.=2;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%format_num();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro format_char(); &lt;/P&gt;&lt;P&gt;data test_char;&lt;/P&gt;&lt;P&gt;%do i=1 %to 2;&lt;/P&gt;&lt;P&gt;if &amp;amp;i.=1 then x&amp;amp;i.="one";&lt;/P&gt;&lt;P&gt;if &amp;amp;i.=2 then x&amp;amp;i.="two";&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%format_char();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro format(); &lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;%do i=1 %to 2;&lt;/P&gt;&lt;P&gt;if &amp;amp;i.=1 then x&amp;amp;i.=1;&lt;/P&gt;&lt;P&gt;if &amp;amp;i.=2 then x&amp;amp;i.="two";&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%format();&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 04:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144733#M28901</guid>
      <dc:creator>armor</dc:creator>
      <dc:date>2014-09-15T04:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating New Variables with %Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144734#M28902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could I suggest that you use the following options:&lt;/P&gt;&lt;P&gt;options mlogic mprint sybolgen;&lt;/P&gt;&lt;P&gt;You can then inspect the log to see why this is occurring.&amp;nbsp; It is then quite simple to see what the problem is:&lt;/P&gt;&lt;P&gt;MLOGIC(FORMAT):&amp;nbsp; Beginning execution.&lt;/P&gt;&lt;P&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; data test;&lt;/P&gt;&lt;P&gt;MLOGIC(FORMAT):&amp;nbsp; %DO loop beginning; index variable I; start value is 1; stop value is 2; by value is 1.&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable I resolves to 1&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable I resolves to 1&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* At this point x1 needs to be created, as the results for the if are numeric, that is the attribute assigned to X1 */&lt;/P&gt;&lt;P&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 1=1 then x1=1;&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable I resolves to 1&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable I resolves to 1&lt;/P&gt;&lt;P&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 1=2 then x1="two";&lt;/P&gt;&lt;P&gt;MLOGIC(FORMAT):&amp;nbsp; %DO loop index variable I is now 2; loop will iterate again.&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable I resolves to 2&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable I resolves to 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* At this point, although the if condition does not resolve to true, the line is still used to assign a numeric to X2 */&lt;/P&gt;&lt;P&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 2=1 then x2=1;&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable I resolves to 2&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp; Macro variable I resolves to 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* And when we get to this point where the if is true the variable already exists as numeric, hence char to number notes */&lt;/P&gt;&lt;P&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 2=2 then x2="two";&lt;/P&gt;&lt;P&gt;MLOGIC(FORMAT):&amp;nbsp; %DO loop index variable I is now 3; loop will not iterate again.&lt;/P&gt;&lt;P&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you could change your macro to look like this:&lt;/P&gt;&lt;P&gt;options mlogic mprint symbolgen;&lt;BR /&gt;%macro format(); &lt;BR /&gt;&amp;nbsp; data test;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do i=1 %to 2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;i.=1 %then %do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&amp;amp;i.=1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;i.=2 %then %do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&amp;amp;i.="two";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;BR /&gt;&amp;nbsp; run;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%format();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I would be more interested to see what you are actually trying to achieve, i.e. why do you need to create lots of possibly numeric or character variables?&amp;nbsp; Maybe assigning a value to them in a datastep then transposing would be better, or arrays, or generating code etc.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 08:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144734#M28902</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-09-15T08:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating New Variables with %Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144735#M28903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The macro processor is processing only text, does not anything about numeric or char of the sas-datastep.&lt;/P&gt;&lt;P&gt;Within the sas datastep you can work with arrays and variable lists. The requirement there is commonly they should be of the same type.&lt;/P&gt;&lt;P&gt;The approach of macro usage here could be an strange way to do something.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am missing the real issue the real problem.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 09:41:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144735#M28903</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-09-15T09:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Creating New Variables with %Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144736#M28904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you look at the code that your macro is generating?&amp;nbsp; Turn on the MPRINT option.&lt;/P&gt;&lt;P&gt;None of those programs make any sense, but the last one generates code that causes error messages.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First you are telling SAS that sometimes you want X2 to have the value 1 so it defines X2 as a number since you tried to assign a number to it the first time it sees any usage of X2.&lt;/P&gt;&lt;P&gt;But then when the step runs the IF 2=2 clause is true so it tries to assign the string "two" to the numeric variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; data test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 1=1 then x1=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 1=2 then x1="two";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 2=1 then x2=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 2=2 then x2="two";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;NOTE: Character values have been converted to numeric&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; values at the places given by: (Line):(Column).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3:43&amp;nbsp;&amp;nbsp; 5:43&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;NOTE: Invalid numeric data, 'two' , at line 5 column 43.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;x1=1 x2=. _ERROR_=1 _N_=1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;NOTE: The data set WORK.TEST has 1 observations and 2 variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 11:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144736#M28904</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-09-15T11:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating New Variables with %Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144737#M28905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Try using this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro format1();&lt;/P&gt;&lt;P&gt;data test1;&lt;/P&gt;&lt;P&gt;%do i=1 %to 100;&lt;BR /&gt;%if %sysfunc(mod(&amp;amp;i.,2))= 0 %then %do;&lt;BR /&gt;x&amp;amp;i.="two"; &lt;BR /&gt;%end;&lt;BR /&gt;%else %do;&lt;BR /&gt;x&amp;amp;i.="1";%end;&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=test1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%format1();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Daman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 12:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144737#M28905</guid>
      <dc:creator>damanaulakh88</dc:creator>
      <dc:date>2014-09-15T12:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Creating New Variables with %Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144738#M28906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks everyone. the sas code by the mprint function explains the observation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*==========================;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; data test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 1=1 then x1=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 1=2 then x1="two";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 2=1 then x2=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; if 2=2 then x2="two";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;MPRINT(FORMAT):&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Sep 2014 16:10:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-New-Variables-with-Do-Loop/m-p/144738#M28906</guid>
      <dc:creator>armor</dc:creator>
      <dc:date>2014-09-15T16:10:47Z</dc:date>
    </item>
  </channel>
</rss>

