<?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 data _null_ and symputx in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202044#M37698</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Reeza and PhilC - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Explicit conversion using PUT helped, but still getting mismatch where only one macro is created, and assigned value of third element in array. &lt;/P&gt;&lt;P&gt;Will keep trying. &lt;/P&gt;&lt;P&gt;Thanks, Shawn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Aug 2015 20:50:29 GMT</pubDate>
    <dc:creator>ShawnMcB</dc:creator>
    <dc:date>2015-08-18T20:50:29Z</dc:date>
    <item>
      <title>Using data _null_ and symputx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202041#M37695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all -&lt;/P&gt;&lt;P&gt;Extending methods seen in a SUGI online paper I am trying to create a series of macro variables on the fly using a DO LOOP and SYMPUTX in a DATA _NULL_ step.&lt;/P&gt;&lt;P&gt;My code and log output from a %put statement are below.&lt;/P&gt;&lt;P&gt;Seemingly, this program only creates the first of an intended three macro variables, while assigning it the third value in the reference array.&lt;/P&gt;&lt;P&gt;Any thoughts as to why, and correction much appreciated.&lt;/P&gt;&lt;P&gt;Thanks, Shawn&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;/***********************/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;data &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;set &amp;amp;tbdta;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;array ciset {*} ci1 ci2 ci3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;do i=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; dim(ciset);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;call symputx(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt; font-family: Courier New;"&gt;'var'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; || &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-size: 10pt; font-family: Courier New;"&gt;'i'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;,vname(ciset{i}));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;end; stop; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;%put _user_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;GLOBAL DIM_VAR 3&lt;/P&gt;&lt;P&gt;GLOBAL MSTRDRV \\Confidential\CoreT&lt;/P&gt;&lt;P&gt;GLOBAL SYSYR 2015&lt;/P&gt;&lt;P&gt;GLOBAL TBDTA tbdtawrk.tbcsdta_2009_06aug2015_int&lt;/P&gt;&lt;P&gt;GLOBAL VARI ci3&lt;/P&gt;&lt;P&gt;GLOBAL YRCTO 1916&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 20:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202041#M37695</guid>
      <dc:creator>ShawnMcB</dc:creator>
      <dc:date>2015-08-18T20:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using data _null_ and symputx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202042#M37696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think 'i' should be in quotes in the symputx function?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 20:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202042#M37696</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2015-08-18T20:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using data _null_ and symputx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202043#M37697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You've placed the character i, not the variable i in the call symput code. I'll usually explicitly convert it and left align as well. &lt;/P&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: #ffffff;"&gt;call symputx(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: #800080; background-color: #ffffff;"&gt;'var'&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: #ffffff;"&gt; || put(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: #800080; background-color: #ffffff;"&gt;i, 2. -l) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: #ffffff;"&gt;,vname(ciset{i}));&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 20:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202043#M37697</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-08-18T20:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using data _null_ and symputx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202044#M37698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Reeza and PhilC - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Explicit conversion using PUT helped, but still getting mismatch where only one macro is created, and assigned value of third element in array. &lt;/P&gt;&lt;P&gt;Will keep trying. &lt;/P&gt;&lt;P&gt;Thanks, Shawn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 20:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202044#M37698</guid>
      <dc:creator>ShawnMcB</dc:creator>
      <dc:date>2015-08-18T20:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using data _null_ and symputx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202045#M37699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't need a STOP, but otherwise works fine for me. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;array ciset {*} ci1 ci2 ci3;&lt;/P&gt;&lt;P&gt;do i=1 to dim(ciset);&lt;/P&gt;&lt;P&gt;call symputx('var' || put(i, 2. -l),vname(ciset{i}));&lt;/P&gt;&lt;P&gt;end; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;var1;&lt;/P&gt;&lt;P&gt;%put &amp;amp;var2;&lt;/P&gt;&lt;P&gt;%put &amp;amp;var3;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 21:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202045#M37699</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-08-18T21:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using data _null_ and symputx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202046#M37700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Code as modified by Reeza is working for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am curious as to where this is going. I'm sure there is a reason for creating the macro variables but I'm not quite sure why, with the example given, you're not using 3 %let statements. The SET statement does nothing for the example code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 21:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202046#M37700</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-08-18T21:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using data _null_ and symputx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202047#M37701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Reeza - &lt;/P&gt;&lt;P&gt;Explicitly transforming i with PUT and L justify worked like a charm. Along with omitting SET and STOP. &lt;/P&gt;&lt;P&gt;First time for everything. &lt;/P&gt;&lt;P&gt;Thanks again. &lt;/P&gt;&lt;P&gt;Shawn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 14:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202047#M37701</guid>
      <dc:creator>ShawnMcB</dc:creator>
      <dc:date>2015-08-19T14:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using data _null_ and symputx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202048#M37702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ballardw - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for correction of omitting SET. Got Reeza's code to work great. Where I am using this is to allow dynamic on the fly assignment of macros to select variables to run in accompanying programming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks to both. &lt;/P&gt;&lt;P&gt;Shawn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 14:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202048#M37702</guid>
      <dc:creator>ShawnMcB</dc:creator>
      <dc:date>2015-08-19T14:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using data _null_ and symputx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202049#M37703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Understand need for the variables but the approach shown isn't very dynamic.&lt;/P&gt;&lt;P&gt;See if this makes sense in your application:&lt;/P&gt;&lt;P&gt;%macro MkVars(list=, stem=);&lt;BR /&gt;/* creates macro variables with values as the words from space delimited list&lt;BR /&gt;named beginning with the stem value and incremented&lt;BR /&gt;up to user at this point to ensure List is not blank, stem is a single "word" and &lt;BR /&gt;starts a valid sas macro variable name*/&lt;BR /&gt;%do i=1 %to&amp;nbsp; %sysfunc(countw(&amp;amp;list,' ')) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; %global &amp;amp;stem&amp;amp;i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; %let &amp;amp;stem&amp;amp;i = %scan(&amp;amp;list,&amp;amp;i);&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%MkVars(list= a b c, stem=letter);&lt;BR /&gt;%put _user_;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 14:51:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-data-null-and-symputx/m-p/202049#M37703</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-08-19T14:51:58Z</dc:date>
    </item>
  </channel>
</rss>

