<?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: Please Help! Assign Macro from Dataset and Recalling from Memory to write into another Data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133463#M27111</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't see where you assign a value to &amp;amp;REF.&amp;nbsp; Is it possible that the %IF &amp;amp;COUNTER=&amp;amp;REF condition is never true?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also note, if you are trying to get the last observation from the data set, there are faster ways to do it.&amp;nbsp; In fact, from the application you are writing, it seems like any observation would do. Shouldn't VarNum return the same value for every observation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 May 2013 01:24:46 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2013-05-10T01:24:46Z</dc:date>
    <item>
      <title>Please Help! Assign Macro from Dataset and Recalling from Memory to write into another Data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133462#M27110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;I can't get the string from memory into my dataset. Instead of going into my Variable, it's coming as a variable by itself! Please help!!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code which runs by itself&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data WORK.TEMP3;&lt;/P&gt;&lt;P&gt; format &lt;/P&gt;&lt;P&gt;&amp;nbsp; CAT $10.&lt;/P&gt;&lt;P&gt;&amp;nbsp; AVG_BY_CAT DOLLAR2.&lt;/P&gt;&lt;P&gt;&amp;nbsp; DATE DDMMYY10.&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt; length&lt;/P&gt;&lt;P&gt;&amp;nbsp; CAT $10.;&lt;/P&gt;&lt;P&gt; INFILE &lt;/P&gt;&lt;P&gt;&amp;nbsp; DATALINES &lt;/P&gt;&lt;P&gt;&amp;nbsp; DLM=',' &lt;/P&gt;&lt;P&gt;&amp;nbsp; DSD;&lt;/P&gt;&lt;P&gt; input&lt;/P&gt;&lt;P&gt;&amp;nbsp; CAT: $10.&lt;/P&gt;&lt;P&gt;&amp;nbsp; AVG_BY_CAT: DOLLAR2.&lt;/P&gt;&lt;P&gt;&amp;nbsp; DATE DDMMYY10.&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt; DATALINES;&lt;/P&gt;&lt;P&gt;DOGS,1,01/01/2001&lt;/P&gt;&lt;P&gt;CATS,2,02/01/2001&lt;/P&gt;&lt;P&gt;HORSE,3,03/01/2001&lt;/P&gt;&lt;P&gt;FISH,4,04/01/2001&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro JT_MACRO(REF);&lt;BR /&gt; %global COUNTER;&lt;BR /&gt; %global thisDOLLAR;&lt;BR /&gt; %global thisDATE;&lt;BR /&gt; %global thisPET;&lt;BR /&gt; %let dsid=%sysfunc(open(TEMP3,i));&lt;BR /&gt; %let nobs=%sysfunc(attrn(&amp;amp;dsid, nobs));&lt;/P&gt;&lt;P&gt; %do i=1 %to &amp;amp;nobs;&lt;BR /&gt;&amp;nbsp; %let rc=%sysfunc(fetch(&amp;amp;dsid));&lt;BR /&gt;&amp;nbsp; %let COUNTER=%sysfunc(GetVarC(&amp;amp;dsid, %sysfunc(VarNum(&amp;amp;dsid, CAT))));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if &amp;amp;COUNTER = &amp;amp;REF %then&lt;BR /&gt;&amp;nbsp;&amp;nbsp; %do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let thisDOLLAR=%sysfunc(GetVarN(&amp;amp;dsid, %sysfunc(VarNum(&amp;amp;dsid, AVG_BY_CAT))));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let thisDATE=%sysfunc(GetVarN(&amp;amp;dsid, %sysfunc(VarNum(&amp;amp;dsid, DATE))));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let thisPET=%sysfunc(GetVarC(&amp;amp;dsid, %sysfunc(VarNum(&amp;amp;dsid, CAT))));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; %end;&lt;BR /&gt; %end;&lt;BR /&gt; %let rc = %sysfunc(close(&amp;amp;dsid));&lt;BR /&gt;%mend JT_MACRO;&lt;BR /&gt;%JT_MACRO(FISH);&lt;BR /&gt;%put --&amp;gt; &amp;amp;thisDOLLAR;&lt;BR /&gt;%put --&amp;gt; &amp;amp;thisDATE;&lt;BR /&gt;%put --&amp;gt; &amp;amp;thisPET;&lt;/P&gt;&lt;P&gt;DATA TEMP4;&lt;BR /&gt; SET TEMP3;&lt;BR /&gt; format MEM_DOLLAR DOLLAR9. MEM_DATE DDMMYY10. MEM_STR $15.;&lt;BR /&gt; length MEM_STR $15.;&lt;BR /&gt; MEM_DOLLAR = &amp;amp;thisDOLLAR;&lt;BR /&gt; MEM_DATE = &amp;amp;thisDATE;&lt;BR /&gt; MEM_STR = &amp;amp;thisPET;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 01:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133462#M27110</guid>
      <dc:creator>tsengj</dc:creator>
      <dc:date>2013-05-10T01:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Please Help! Assign Macro from Dataset and Recalling from Memory to write into another Data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133463#M27111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't see where you assign a value to &amp;amp;REF.&amp;nbsp; Is it possible that the %IF &amp;amp;COUNTER=&amp;amp;REF condition is never true?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also note, if you are trying to get the last observation from the data set, there are faster ways to do it.&amp;nbsp; In fact, from the application you are writing, it seems like any observation would do. Shouldn't VarNum return the same value for every observation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 01:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133463#M27111</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-05-10T01:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Please Help! Assign Macro from Dataset and Recalling from Memory to write into another Data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133464#M27112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tsengj,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the last datastep, assign quotation for the MEM_STR Varaible&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA TEMP4;&lt;BR /&gt;SET TEMP3;&lt;BR /&gt;format MEM_DOLLAR DOLLAR9. MEM_DATE DDMMYY10. MEM_STR $15.;&lt;BR /&gt;length MEM_STR $15.;&lt;BR /&gt;MEM_DOLLAR = &amp;amp;thisDOLLAR;&lt;BR /&gt;MEM_DATE = &amp;amp;thisDATE;&lt;BR /&gt;MEM_STR = "&amp;amp;thisPET";&lt;BR /&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 01:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133464#M27112</guid>
      <dc:creator>siliveri4uall</dc:creator>
      <dc:date>2013-05-10T01:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Please Help! Assign Macro from Dataset and Recalling from Memory to write into another Data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133465#M27113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Before you begin attempting to write macro code you need to understand what SAS code you want the macro logic to generate.&amp;nbsp; For your issue the problem is that to assign a text literal to character variable in a data step you need to enclose the value in quotes.&amp;nbsp; If you want macro references in the text string to be expanded then use double quotes.&lt;/P&gt;&lt;P&gt;MEM_STR = "&amp;amp;thisPET" ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Normally you would not want use macro variables to move values from&amp;nbsp; one dataset to&amp;nbsp; another as SAS has many language features (SET, MERGE, PROC SQL) to allow you to do that without first converting the values into character strings in macro variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you just playing around to understand macro coding or do you have an actual problem that you are trying to solve?&amp;nbsp; If you can explain it then perhaps there is an easier way to do what you need.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 01:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133465#M27113</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-05-10T01:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Please Help! Assign Macro from Dataset and Recalling from Memory to write into another Data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133466#M27114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just playing around but i know i'll need to reference Macro generated when i created data sets. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 01:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133466#M27114</guid>
      <dc:creator>tsengj</dc:creator>
      <dc:date>2013-05-10T01:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Please Help! Assign Macro from Dataset and Recalling from Memory to write into another Data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133467#M27115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bingo! Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 02:04:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-Help-Assign-Macro-from-Dataset-and-Recalling-from-Memory/m-p/133467#M27115</guid>
      <dc:creator>tsengj</dc:creator>
      <dc:date>2013-05-10T02:04:16Z</dc:date>
    </item>
  </channel>
</rss>

