<?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: How to print values between two particular integers in SAS using Do, Do-While loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-values-between-two-particular-integers-in-SAS-using/m-p/307393#M65825</link>
    <description>&lt;P&gt;try next code, assuming you have X_1 and Y variables in a dataset::&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%LET start = 8;&lt;/P&gt;
&lt;P&gt;%LET stop = 15;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have; &amp;nbsp;/* input of X_1 and Y variables */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; length x_&amp;amp;start - x_&amp;amp;stop 8;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; array x_n&amp;nbsp;&lt;SPAN&gt;x_&amp;amp;start - x_&amp;amp;stop ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; do i=&amp;amp;start to &amp;amp;stop;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;j = i - &amp;amp;start +1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x_n(j) = x_1 + (i/15)*Y; &amp;nbsp; /* no need of all other brackets */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc print data=want;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var &amp;nbsp;x_1 y x_&amp;amp;start - x_&amp;amp;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Oct 2016 13:51:11 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2016-10-26T13:51:11Z</dc:date>
    <item>
      <title>How to print values between two particular integers in SAS using Do, Do-While loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-values-between-two-particular-integers-in-SAS-using/m-p/307374#M65817</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS programming. I am finding way to solve the following problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The existing program prints 2 to 15 levels output by default. If I would like to print only the levels between a particular value (say &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; and 15, how do I achieve it using do or do-while loop.&lt;/P&gt;&lt;P&gt;Current sample output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;x_2 = x_1+(((1)/15)*y;&lt;BR /&gt;x_3 =x_1+(((2)/15)*y);&lt;BR /&gt;.&lt;BR /&gt;.&lt;/P&gt;&lt;P&gt;.&lt;BR /&gt;x_15 = x_1+(((14)/15)*y);&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 13:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-print-values-between-two-particular-integers-in-SAS-using/m-p/307374#M65817</guid>
      <dc:creator>akhilesh_joshi</dc:creator>
      <dc:date>2016-10-26T13:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to print values between two particular integers in SAS using Do, Do-While loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-values-between-two-particular-integers-in-SAS-using/m-p/307393#M65825</link>
      <description>&lt;P&gt;try next code, assuming you have X_1 and Y variables in a dataset::&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%LET start = 8;&lt;/P&gt;
&lt;P&gt;%LET stop = 15;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have; &amp;nbsp;/* input of X_1 and Y variables */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; length x_&amp;amp;start - x_&amp;amp;stop 8;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; array x_n&amp;nbsp;&lt;SPAN&gt;x_&amp;amp;start - x_&amp;amp;stop ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; do i=&amp;amp;start to &amp;amp;stop;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;j = i - &amp;amp;start +1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x_n(j) = x_1 + (i/15)*Y; &amp;nbsp; /* no need of all other brackets */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;proc print data=want;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var &amp;nbsp;x_1 y x_&amp;amp;start - x_&amp;amp;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 13:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-print-values-between-two-particular-integers-in-SAS-using/m-p/307393#M65825</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-26T13:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to print values between two particular integers in SAS using Do, Do-While loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-values-between-two-particular-integers-in-SAS-using/m-p/307397#M65827</link>
      <description>&lt;P&gt;Please examine the instructions for posting questions. &amp;nbsp;Post example test data, in the form of a datastep. &amp;nbsp;And what you want the output to look like. &amp;nbsp;Also describe any formula to achieve the output. &amp;nbsp;I am afraid the given text does not describe the problem in any detail neede to give you an answer.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 13:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-print-values-between-two-particular-integers-in-SAS-using/m-p/307397#M65827</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-26T13:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to print values between two particular integers in SAS using Do, Do-While loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-values-between-two-particular-integers-in-SAS-using/m-p/307398#M65828</link>
      <description>&lt;P&gt;It kind of helps to have some example input values and the actual desired output. And since you already have a program the entire program or at least the data step the example code came from. Since you do not show a PUT statement then you should clarify what you mean by "print" as there does not appear to be any "print" type output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are you telling the program that you want 8 to 15? Hard code in the program, based on the value of other variables in the dataset or something you provide interactively?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also on this forum please do not post duplicate posts. If the post belongs in another topic area then you may get a suggestion to post the (possibly improved) question in an appropriate area or sometimes the post will be merged.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Duplicate posts end up with confusion as you get questions about your requirement that are answered in one thread but not the other and you feel "but I already answered that". Also others searching the forum may not find the thread with the accepted solution in the future.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2016 13:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-print-values-between-two-particular-integers-in-SAS-using/m-p/307398#M65828</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-26T13:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to print values between two particular integers in SAS using Do, Do-While loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-print-values-between-two-particular-integers-in-SAS-using/m-p/307420#M65837</link>
      <description>&lt;P&gt;Hi Ballardw,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wil try to be more concise and would avoid duplicate posts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already have x_1 and x_16. Currently, the program creates columns x_2 to x_15 in output data created after I run the program. Instead, I want to declare a variable say x_(number) where I can input a number of my choice say (10) to have columns only from that number(x_10) to x_16. y is X_16 - X_1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so instead of x_1 I want to output to start from x_(number) so that x_(number) is my new x_1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I create x_2 to x_15 currently by using&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;x_2 = x_1 + ((1)/15)*y);&lt;/P&gt;&lt;P&gt;x_3 = x_1 + ((2/15)*y);&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;x_15 = x_1 + ((14/15)*y);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I include them in output data using&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA = name_of_data (KEEP = x_1 x_16 x_2 x_3 x_4 x_5 x_6 x_7 x_8 x_9 x_10 x_11 x_12 x_13 x_14 x_15)&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, 26 Oct 2016 14:36:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-print-values-between-two-particular-integers-in-SAS-using/m-p/307420#M65837</guid>
      <dc:creator>akhilesh_joshi</dc:creator>
      <dc:date>2016-10-26T14:36:19Z</dc:date>
    </item>
  </channel>
</rss>

