<?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: assign select %let variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/assign-select-let-variables/m-p/554484#M9512</link>
    <description>&lt;P&gt;Certainly you need a source of information that could reproduce any of the million macro variables.&amp;nbsp; I would suggest keeping it as a SAS data set with three variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Step&amp;nbsp; (the step that needs this macro variable)&lt;/LI&gt;
&lt;LI&gt;Name&amp;nbsp; (the name of the macro variable)&lt;/LI&gt;
&lt;LI&gt;Value&amp;nbsp; (the value to assign to this macro variable)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Then your step1.sas program could do something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set source_of_information;&lt;/P&gt;
&lt;P&gt;where step = "Step 1";&lt;/P&gt;
&lt;P&gt;call symputx(name, value);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Sat, 27 Apr 2019 15:42:35 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-04-27T15:42:35Z</dc:date>
    <item>
      <title>assign select %let variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/assign-select-let-variables/m-p/554260#M9475</link>
      <description>&lt;P&gt;My "step1.sas"&amp;nbsp;holds all my libnames &amp;amp; %let variables. It's supposed to be a master archive of libnames and variables to be used in other subsequent&amp;nbsp;sas programs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because I don't want a million libnames to be assigned automatically in my sas steps 2-10, Step1.sas also has a macro sql procedure that only assigns select libnames to certain steps. For example, if my step3.sas only needs a libname called "input7", then my step1.sas has the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%Let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; STEP3_PATHS=;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;reset&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;distinct&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;"LIBNAME "&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; || libname&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; : STEP3_PATHS separated &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;";"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; DICTIONARY.LIBNAMES&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; libname not &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;in&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'LIST OF LIBNAMES TO KEEP or CANT BE CLEARED'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'WORK'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'SASUSER'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'SASHELP'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'MAPSSAS'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'MAPSGFK'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'MAPS'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'INPUT7'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;------------------------------------------&lt;/P&gt;&lt;P&gt;And in my step3.sas, I call up step1.sas &amp;amp; step3-specific libnames&amp;nbsp;with:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%include&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;"C:\Users\myname\Step1.sas"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;amp;STEP3_PATHS;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;------------------------------------------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to be able to duplicate this libname sql for %let variables. I don't want a million %let variables to be assigned when I use &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%include&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;"C:\Users\myname\Step1.sas"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead, when I run step3.sas, I only want a few&amp;nbsp;relevant&amp;nbsp;%let variables to be called up from step1.sas.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts on how to accomplish this? Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 13:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/assign-select-let-variables/m-p/554260#M9475</guid>
      <dc:creator>LFern</dc:creator>
      <dc:date>2019-04-26T13:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: assign select %let variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/assign-select-let-variables/m-p/554484#M9512</link>
      <description>&lt;P&gt;Certainly you need a source of information that could reproduce any of the million macro variables.&amp;nbsp; I would suggest keeping it as a SAS data set with three variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Step&amp;nbsp; (the step that needs this macro variable)&lt;/LI&gt;
&lt;LI&gt;Name&amp;nbsp; (the name of the macro variable)&lt;/LI&gt;
&lt;LI&gt;Value&amp;nbsp; (the value to assign to this macro variable)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Then your step1.sas program could do something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set source_of_information;&lt;/P&gt;
&lt;P&gt;where step = "Step 1";&lt;/P&gt;
&lt;P&gt;call symputx(name, value);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Apr 2019 15:42:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/assign-select-let-variables/m-p/554484#M9512</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-27T15:42:35Z</dc:date>
    </item>
  </channel>
</rss>

