<?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: Do loop to create multiple variables in single data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/458264#M116262</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

set sashelp.class; *source data;

    do Col2 = 1 to 3;

        Col3 = 50 + Col2;
        output;

    end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Key idea is the explicit OUTPUT statement that controls the output and prints the multiple records.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/178437"&gt;@vpgodbole&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi , i want to create 2 variables in same data step.&lt;/P&gt;
&lt;P&gt;One containing iteration of 1 to&amp;nbsp;3&amp;nbsp;and other storing iteration of 51-53.&lt;/P&gt;
&lt;P&gt;and i want to do it by&amp;nbsp;a key variable ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data is like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;ID&lt;/P&gt;
&lt;P&gt;101&lt;/P&gt;
&lt;P&gt;102&lt;/P&gt;
&lt;P&gt;103&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The desired output:&lt;/P&gt;
&lt;P&gt;101&amp;nbsp; 1&amp;nbsp; 51&lt;/P&gt;
&lt;P&gt;101&amp;nbsp; 2&amp;nbsp; 52&lt;/P&gt;
&lt;P&gt;101&amp;nbsp; 3&amp;nbsp; 53&lt;/P&gt;
&lt;P&gt;102&amp;nbsp; 1&amp;nbsp; 51&lt;/P&gt;
&lt;P&gt;102&amp;nbsp; 2&amp;nbsp; 52&lt;/P&gt;
&lt;P&gt;102&amp;nbsp; 2&amp;nbsp; 53&lt;/P&gt;
&lt;P&gt;103&amp;nbsp; 1&amp;nbsp; 51&lt;/P&gt;
&lt;P&gt;103&amp;nbsp; 2&amp;nbsp; 52&lt;/P&gt;
&lt;P&gt;103&amp;nbsp; 3&amp;nbsp; 53&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did it for each with do loop and merged, but looking for way to do in one step. Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Apr 2018 21:26:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-04-27T21:26:31Z</dc:date>
    <item>
      <title>Do loop to create multiple variables in single data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/458263#M116261</link>
      <description>&lt;P&gt;Hi , i want to create 2 variables in same data step.&lt;/P&gt;&lt;P&gt;One containing iteration of 1 to&amp;nbsp;3&amp;nbsp;and other storing iteration of 51-53.&lt;/P&gt;&lt;P&gt;and i want to do it by&amp;nbsp;a key variable ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;ID&lt;/P&gt;&lt;P&gt;101&lt;/P&gt;&lt;P&gt;102&lt;/P&gt;&lt;P&gt;103&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The desired output:&lt;/P&gt;&lt;P&gt;101&amp;nbsp; 1&amp;nbsp; 51&lt;/P&gt;&lt;P&gt;101&amp;nbsp; 2&amp;nbsp; 52&lt;/P&gt;&lt;P&gt;101&amp;nbsp; 3&amp;nbsp; 53&lt;/P&gt;&lt;P&gt;102&amp;nbsp; 1&amp;nbsp; 51&lt;/P&gt;&lt;P&gt;102&amp;nbsp; 2&amp;nbsp; 52&lt;/P&gt;&lt;P&gt;102&amp;nbsp; 2&amp;nbsp; 53&lt;/P&gt;&lt;P&gt;103&amp;nbsp; 1&amp;nbsp; 51&lt;/P&gt;&lt;P&gt;103&amp;nbsp; 2&amp;nbsp; 52&lt;/P&gt;&lt;P&gt;103&amp;nbsp; 3&amp;nbsp; 53&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did it for each with do loop and merged, but looking for way to do in one step. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 21:22:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/458263#M116261</guid>
      <dc:creator>vpgodbole</dc:creator>
      <dc:date>2018-04-27T21:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop to create multiple variables in single data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/458264#M116262</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;

set sashelp.class; *source data;

    do Col2 = 1 to 3;

        Col3 = 50 + Col2;
        output;

    end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Key idea is the explicit OUTPUT statement that controls the output and prints the multiple records.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/178437"&gt;@vpgodbole&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi , i want to create 2 variables in same data step.&lt;/P&gt;
&lt;P&gt;One containing iteration of 1 to&amp;nbsp;3&amp;nbsp;and other storing iteration of 51-53.&lt;/P&gt;
&lt;P&gt;and i want to do it by&amp;nbsp;a key variable ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data is like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;ID&lt;/P&gt;
&lt;P&gt;101&lt;/P&gt;
&lt;P&gt;102&lt;/P&gt;
&lt;P&gt;103&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The desired output:&lt;/P&gt;
&lt;P&gt;101&amp;nbsp; 1&amp;nbsp; 51&lt;/P&gt;
&lt;P&gt;101&amp;nbsp; 2&amp;nbsp; 52&lt;/P&gt;
&lt;P&gt;101&amp;nbsp; 3&amp;nbsp; 53&lt;/P&gt;
&lt;P&gt;102&amp;nbsp; 1&amp;nbsp; 51&lt;/P&gt;
&lt;P&gt;102&amp;nbsp; 2&amp;nbsp; 52&lt;/P&gt;
&lt;P&gt;102&amp;nbsp; 2&amp;nbsp; 53&lt;/P&gt;
&lt;P&gt;103&amp;nbsp; 1&amp;nbsp; 51&lt;/P&gt;
&lt;P&gt;103&amp;nbsp; 2&amp;nbsp; 52&lt;/P&gt;
&lt;P&gt;103&amp;nbsp; 3&amp;nbsp; 53&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did it for each with do loop and merged, but looking for way to do in one step. Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 21:26:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/458264#M116262</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-27T21:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop to create multiple variables in single data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/458265#M116263</link>
      <description>&lt;P&gt;nice quiz:&lt;/P&gt;&lt;P&gt;more fun &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id;
cards;
101
102
103
;

data want;
set have;
do n1=51 to 53;
n2=mod(n1,10);
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 21:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/458265#M116263</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-27T21:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop to create multiple variables in single data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/459123#M116578</link>
      <description>&lt;P&gt;Thank you all for the comments:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have names of adjusters and want to assign week 1 to 52 for all and another variable in the same data step assigning start date for each week. Start date of 1st week of year goes by -&amp;nbsp; sum(intnx('week','01JAN2018'd,1),-7)&amp;nbsp; to&amp;nbsp;&amp;nbsp;sum(intnx('week','31DEC2018'd,1),-7)&amp;nbsp; by&amp;nbsp; 7.&amp;nbsp;&amp;nbsp;That way I have the corresponding start date of each week.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In am not able to bring this in 1 step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output should look like:&lt;/P&gt;&lt;P&gt;ADJUSTER&amp;nbsp; &amp;nbsp; WEEK&amp;nbsp; &amp;nbsp;Start Dt&lt;/P&gt;&lt;P&gt;PAUL&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; 31DEC2018&lt;/P&gt;&lt;P&gt;PAUL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07JAN2018&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;PAUL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;53&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;30DEC2018&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;KATHRYN&amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31DEC2018&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;KATHRYN&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;07JAN2018&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;KATHRYN&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;53&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;30DEC2018&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!&lt;/P&gt;&lt;P&gt;Varun&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 21:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/459123#M116578</guid>
      <dc:creator>vpgodbole</dc:creator>
      <dc:date>2018-05-01T21:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop to create multiple variables in single data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/459126#M116579</link>
      <description>&lt;P&gt;Can you please post a clear sample of what you &lt;EM&gt;&lt;STRONG&gt;have&lt;/STRONG&gt; &lt;/EM&gt;and what you &lt;EM&gt;&lt;STRONG&gt;want&lt;/STRONG&gt; &lt;/EM&gt;and the logic in plain english(not intnx code) so that it is convenient for respondents to think through and offer you various solutions&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 21:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/459126#M116579</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-01T21:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop to create multiple variables in single data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/459128#M116580</link>
      <description>&lt;P&gt;My apologies. Sure, all I have with me is list of names of adjusters which I got by nodupkey on adjuster column in dataset.&lt;/P&gt;&lt;P&gt;PAUL&lt;/P&gt;&lt;P&gt;KATHRYN&lt;/P&gt;&lt;P&gt;EMMA&lt;/P&gt;&lt;P&gt;VICTOR&lt;/P&gt;&lt;P&gt;SAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I want to create 2 variables 1 storing week number and another storing start date of the week. This is a dummy dataset i am using to merge with the adjuster&amp;nbsp;claim counts&amp;nbsp;I have. So the weeks where adjuster doesn't have any&amp;nbsp;data the count will be zero.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output should look like:&lt;/P&gt;&lt;P&gt;ADJUSTER&amp;nbsp; &amp;nbsp; WEEK&amp;nbsp; &amp;nbsp;Start Dt&lt;/P&gt;&lt;P&gt;PAUL&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; 31DEC2018&lt;/P&gt;&lt;P&gt;PAUL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07JAN2018&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;PAUL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;53&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;30DEC2018&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;KATHRYN&amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31DEC2018&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;KATHRYN&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;07JAN2018&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;KATHRYN&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;53&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;30DEC2018&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 21:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/459128#M116580</guid>
      <dc:creator>vpgodbole</dc:creator>
      <dc:date>2018-05-01T21:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop to create multiple variables in single data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/459129#M116581</link>
      <description>&lt;P&gt;1. Find the start of the year&lt;/P&gt;
&lt;P&gt;2. Use INTNX to increment that to the Sunday&lt;/P&gt;
&lt;P&gt;3. Use a DO loop to increment through to 52/53 and add 7 to the date each time.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/178437"&gt;@vpgodbole&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;My apologies. Sure, all I have with me is list of names of adjusters which I got by nodupkey on adjuster column in dataset.&lt;/P&gt;
&lt;P&gt;PAUL&lt;/P&gt;
&lt;P&gt;KATHRYN&lt;/P&gt;
&lt;P&gt;EMMA&lt;/P&gt;
&lt;P&gt;VICTOR&lt;/P&gt;
&lt;P&gt;SAM&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and I want to create 2 variables 1 storing week number and another storing start date of the week. This is a dummy dataset i am using to merge with the adjuster&amp;nbsp;claim counts&amp;nbsp;I have. So the weeks where adjuster doesn't have any&amp;nbsp;data the count will be zero.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output should look like:&lt;/P&gt;
&lt;P&gt;ADJUSTER&amp;nbsp; &amp;nbsp; WEEK&amp;nbsp; &amp;nbsp;Start Dt&lt;/P&gt;
&lt;P&gt;PAUL&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; 31DEC2018&lt;/P&gt;
&lt;P&gt;PAUL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 07JAN2018&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;PAUL&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;53&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;30DEC2018&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;KATHRYN&amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31DEC2018&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;KATHRYN&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;07JAN2018&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;KATHRYN&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;53&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;30DEC2018&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 21:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/459129#M116581</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-01T21:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop to create multiple variables in single data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/459153#M116588</link>
      <description>&lt;P&gt;Have I got this logic right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You currently have just a list of names. You want to expand that so that for each name you have one observation for each week of the year, with a variable for the week number, and a variable for the start date of that week where weeks start on a Sunday.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that is correct then the below should get you what you want. It will output 52 or 53 observations per name, depending on how close Sunday is to the start of the year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
informat adjuster $20.;
input adjuster;
datalines;
PAUL
KATHRYN
EMMA
VICTOR
SAM
;run;

data want;
set have;
format StartDt date9.;
drop EndDt; /* This is just used to check if we've entered enough weeks to cover the year */
Week= 1;
EndDt= intnx('year',date(),0,'E'); /* End of current year */
StartDt= intnx('year',EndDt,-1,'E'); /* End of last year */
StartDt= intnx('week',StartDt,1,'B'); /* First Sunday of current year */
do while (StartDt &amp;lt;= EndDt);
	output; /* We started with values for week 1 so output a record immediately */
	Week= Week+1; /* Increment the week counter by 1 */
	StartDt= StartDt+7; /* A week is always 7 days long so increment date by 7 */
	/* Another loop will start as long as StartDt is still in the current year */
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code assumes week 1 starts on the first Sunday of the year, with any days before that belonging to the last week of the previous year.&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 00:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-to-create-multiple-variables-in-single-data-step/m-p/459153#M116588</guid>
      <dc:creator>JChambo</dc:creator>
      <dc:date>2018-05-02T00:00:06Z</dc:date>
    </item>
  </channel>
</rss>

