<?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 do I create new variables based on entry in Let statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120155#M293494</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;EXACTLY what I wanted. Thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Nov 2012 21:52:39 GMT</pubDate>
    <dc:creator>BN_RN17</dc:creator>
    <dc:date>2012-11-08T21:52:39Z</dc:date>
    <item>
      <title>How do I create new variables based on entry in Let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120150#M293489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is somewhat of an odd request, but hopefully someone can help me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to create new variables for each value entered into a %let statement. Ideally, I would like to have a statement:&lt;/P&gt;&lt;P&gt;%let summary_vars = ____________ where they would then list the summary vars (whether separated by spaces or commas, whichever works). I would then like those to each be a separate variable (can just be numbered), and to work on any number of vars entered.&lt;/P&gt;&lt;P&gt;So, for example:&lt;/P&gt;&lt;P&gt;%let summary_vars = outstanding, exercise, total&lt;/P&gt;&lt;P&gt;WOULD RESULT IN:&lt;/P&gt;&lt;P&gt;summary_vars1 = outstanding&lt;/P&gt;&lt;P&gt;summary_vars2 = exercise&lt;/P&gt;&lt;P&gt;summary_vars3 = total&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 23:09:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120150#M293489</guid>
      <dc:creator>BN_RN17</dc:creator>
      <dc:date>2012-11-07T23:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create new variables based on entry in Let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120151#M293490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; It's not really clear to me what you are trying to do. How would you use summary_vars1, summary_vars2 and summary_vars3. Would "outstanding", "exercise" and "total" already be variables in a data sets? What code have you tried and what are you trying to achieve? What does your input data look like? And what are your desired results?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 23:22:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120151#M293490</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2012-11-07T23:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create new variables based on entry in Let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120152#M293491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you looking for something like the following?:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let summary_vars = outstanding, exercise, total;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input outstanding exercise total;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;1 2 3&lt;/P&gt;&lt;P&gt;4 5 6&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array summary_vars(3);&lt;/P&gt;&lt;P&gt;&amp;nbsp; _n_=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do while (scan("&amp;amp;summary_vars",_n_) ne "");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; summary_vars(_n_)=vvaluex(scan("&amp;amp;summary_vars",_n_));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _n_+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 23:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120152#M293491</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-07T23:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create new variables based on entry in Let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120153#M293492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you both for your responses.&lt;/P&gt;&lt;P&gt;I apologize for my lack of clarity. There will be empty let statements for users to fill in. The summary_vars are not already variables, they are put in by user. The output should result in one line of results - the headers (summary_var1, summary_var2...) and the results (outstanding, total...). So it should look something like this:&lt;IMG alt="Capture.JPG" class="jive-image" src="https://communities.sas.com/legacyfs/online/2689_Capture.JPG" /&gt;&lt;BR /&gt;Arthur - the data test portion is not needed because there is no additional information, but the data want looks promising. I need the array to be dynamic based on the number of items in summary_var %let statment. Then I would just need the values to be read into each summary_var in the array.&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 21:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120153#M293492</guid>
      <dc:creator>BN_RN17</dc:creator>
      <dc:date>2012-11-08T21:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create new variables based on entry in Let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120154#M293493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Still not clear what the input is.&amp;nbsp; Is it a macro variable?&amp;nbsp; (that is what a %LET statement can create)&lt;/P&gt;&lt;P&gt;Still not clear what the output is. Do you want a SAS dataset as in the example from Art?&amp;nbsp; Or just a report? &lt;/P&gt;&lt;P&gt;Assuming that you have an input macro variable that I will call VARLIST here is a simple data step to populate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%*&amp;nbsp; Create an example input ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let varlist=total,outstanding,exercise,freq;&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;* Create dataset WANT using ARRAY statement with initial values ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; array summary_var (%sysfunc(countw("&amp;amp;varlist",%str(,)))) $32&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; (%sysfunc(tranwrd("&amp;amp;varlist",%str(,),",")))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc print ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&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;&amp;nbsp; summary_&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; summary_&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; summary_&amp;nbsp;&amp;nbsp;&amp;nbsp; summary_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; total&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outstanding&amp;nbsp;&amp;nbsp;&amp;nbsp; exercise&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; freq&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 21:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120154#M293493</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-11-08T21:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create new variables based on entry in Let statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120155#M293494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;EXACTLY what I wanted. Thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 21:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-new-variables-based-on-entry-in-Let-statement/m-p/120155#M293494</guid>
      <dc:creator>BN_RN17</dc:creator>
      <dc:date>2012-11-08T21:52:39Z</dc:date>
    </item>
  </channel>
</rss>

