<?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: Using the &amp;quot;DO UNTIL&amp;quot; loop to create long data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-the-quot-DO-UNTIL-quot-loop-to-create-long-data-set/m-p/457408#M115967</link>
    <description>&lt;P&gt;You're on the right track.&amp;nbsp; Here are some slight changes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; simulation1&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;SET&lt;/SPAN&gt; COLLEGES&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;BY&lt;/SPAN&gt; COLLEGE1&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;value = .;&lt;BR /&gt;&lt;SPAN class="token function"&gt;do year&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;2012 to 2017&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; do category='PR', 'AB', 'XY';&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;END&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;RUN&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;You will have to fill in the actual values for CATEGORY.&amp;nbsp; Also, put the longest value first.&amp;nbsp; The first value in the list determines how many characters get used to store CATEGORY.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;****************** EDITED:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Needs a slight change.&amp;nbsp; Should be:&amp;nbsp; do year = 201&lt;FONT color="#ff0000"&gt;3&lt;/FONT&gt; to 2017;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Apr 2018 17:32:47 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-04-25T17:32:47Z</dc:date>
    <item>
      <title>Using the "DO UNTIL" loop to create long data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-quot-DO-UNTIL-quot-loop-to-create-long-data-set/m-p/457401#M115964</link>
      <description>&lt;P&gt;I need to use iterative processing to create a data set with one row per College, per year, per Category value. I set the values to missing in this step. With the following code, I can simulate the data set for just one level of the "Category" variable (the value 'PR'), but I can't seem to figure out how to do this for the other two levels of category. Something tells me that I need to find a way to process a loop within the loop, but I can't find a resource to help with that. Does anyone have any tips?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data colleges; *This college variable has seven levels.;
input college1 $;
cards;
ORG_A
ORG_B
ORG_C
ORG_D
ORG_E
ORG_F
ORG_G
;
RUN;
PROC SORT DATA=COLLEGES;
BY COLLEGE1;
RUN;


data simulation1;
SET COLLEGES;
BY COLLEGE1;
year = 2012;
do until (year = 2017);
   year + 1;
   CATEGORY = 'PR'; *This creates an output data set with 35 observations, but CATEGORY has two other levels, so I need a data set with 105 observations;
   value = .;
   output;
END;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Apr 2018 17:03:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-quot-DO-UNTIL-quot-loop-to-create-long-data-set/m-p/457401#M115964</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2018-04-25T17:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using the "DO UNTIL" loop to create long data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-quot-DO-UNTIL-quot-loop-to-create-long-data-set/m-p/457403#M115965</link>
      <description>&lt;P&gt;How about providing something that actually looks like your input data and the desired output?&lt;/P&gt;
&lt;P&gt;It is very likely that Proc Transpose will do what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 17:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-quot-DO-UNTIL-quot-loop-to-create-long-data-set/m-p/457403#M115965</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-25T17:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using the "DO UNTIL" loop to create long data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-quot-DO-UNTIL-quot-loop-to-create-long-data-set/m-p/457408#M115967</link>
      <description>&lt;P&gt;You're on the right track.&amp;nbsp; Here are some slight changes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; simulation1&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;SET&lt;/SPAN&gt; COLLEGES&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;BY&lt;/SPAN&gt; COLLEGE1&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;value = .;&lt;BR /&gt;&lt;SPAN class="token function"&gt;do year&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;2012 to 2017&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; do category='PR', 'AB', 'XY';&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;END&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;RUN&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;You will have to fill in the actual values for CATEGORY.&amp;nbsp; Also, put the longest value first.&amp;nbsp; The first value in the list determines how many characters get used to store CATEGORY.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;****************** EDITED:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Needs a slight change.&amp;nbsp; Should be:&amp;nbsp; do year = 201&lt;FONT color="#ff0000"&gt;3&lt;/FONT&gt; to 2017;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 17:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-quot-DO-UNTIL-quot-loop-to-create-long-data-set/m-p/457408#M115967</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-25T17:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using the "DO UNTIL" loop to create long data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-quot-DO-UNTIL-quot-loop-to-create-long-data-set/m-p/457414#M115971</link>
      <description>&lt;P&gt;Here is the final output data set. This data set needs to be reproduced for two other levels of the variable Category.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ata WORK.SIMULATION1;
  infile datalines dsd truncover;
  input college1:$8. year:32. CATEGORY:$2. value:32.;
datalines4;
ORG_A,2013,PR,
ORG_A,2014,PR,
ORG_A,2015,PR,
ORG_A,2016,PR,
ORG_A,2017,PR,
ORG_B,2013,PR,
ORG_B,2014,PR,
ORG_B,2015,PR,
ORG_B,2016,PR,
ORG_B,2017,PR,
ORG_C,2013,PR,
ORG_C,2014,PR,
ORG_C,2015,PR,
ORG_C,2016,PR,
ORG_C,2017,PR,
ORG_D,2013,PR,
ORG_D,2014,PR,
ORG_D,2015,PR,
ORG_D,2016,PR,
ORG_D,2017,PR,
ORG_E,2013,PR,
ORG_E,2014,PR,
ORG_E,2015,PR,
ORG_E,2016,PR,
ORG_E,2017,PR,
ORG_F,2013,PR,
ORG_F,2014,PR,
ORG_F,2015,PR,
ORG_F,2016,PR,
ORG_F,2017,PR,
ORG_G,2013,PR,
ORG_G,2014,PR,
ORG_G,2015,PR,
ORG_G,2016,PR,
ORG_G,2017,PR,
;;;;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Apr 2018 17:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-quot-DO-UNTIL-quot-loop-to-create-long-data-set/m-p/457414#M115971</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2018-04-25T17:30:32Z</dc:date>
    </item>
  </channel>
</rss>

