<?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: macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584348#M166417</link>
    <description>&lt;P&gt;I suspect the macro quoting is causing problems.&amp;nbsp; It *should* work fine, but sometimes that macro quoting is not automatically removed like it should be.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let patients=002 003 004;
%let j=2;
%let shortID=%scan(&amp;amp;Patients,&amp;amp;j.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If it does, that would confirm it's a macro unquoting problem.&amp;nbsp; You could either avoid the macro quoting (as above) or explicitly %unquote the value with something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT OUT=wear%unquote(&amp;amp;shortID)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 27 Aug 2019 19:55:05 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2019-08-27T19:55:05Z</dc:date>
    <item>
      <title>macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584323#M166401</link>
      <description>&lt;P&gt;I tried to import data from excel, the method1 does not work, but the method2 work, I don't know why.&lt;/P&gt;&lt;P&gt;(1) method1:&lt;/P&gt;&lt;P&gt;%let patients=002 003 004;&lt;BR /&gt;%let j=2;&lt;BR /&gt;%let shortID=%qscan(%superQ(Patients),&amp;amp;j.);*the patient ID of the jth patient from the Patients list;&lt;BR /&gt;filename wear "/data/work/sasusers/jxs004/GingerYang/ReAct/data/original data from ReAct/Actigraph New/&amp;amp;shortID./&amp;amp;shortID. scoring with sleep.xlsx";&lt;BR /&gt;PROC IMPORT OUT=wear&amp;amp;shortID. DATAFILE=wear DBMS=xlsx REPLACE; SHEET="Daily"; GETNAMES=YES;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(2)method2:&lt;/P&gt;&lt;P&gt;%let shortID=003;&lt;BR /&gt;filename wear "/data/work/sasusers/jxs004/GingerYang/ReAct/data/original data from ReAct/Actigraph New/&amp;amp;shortID./&amp;amp;shortID. scoring with sleep.xlsx";&lt;BR /&gt;PROC IMPORT OUT=wear&amp;amp;shortID. DATAFILE=wear DBMS=xlsx REPLACE; SHEET="Daily"; GETNAMES=YES;RUN;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 18:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584323#M166401</guid>
      <dc:creator>JShi</dc:creator>
      <dc:date>2019-08-27T18:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584325#M166403</link>
      <description>&lt;P&gt;Are there errors in the SAS log?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Show us the log by clicking on the {i} icon and pasting the log into the window that appears. Do not provide the log any other way. Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 19:00:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584325#M166403</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-27T19:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584328#M166404</link>
      <description>&lt;P&gt;Add the following options to your code, and check your log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint symbolgen;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Put that before your code, run it and then check your log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286896"&gt;@JShi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried to import data from excel, the method1 does not work, but the method2 work, I don't know why.&lt;/P&gt;
&lt;P&gt;(1) method1:&lt;/P&gt;
&lt;P&gt;%let patients=002 003 004;&lt;BR /&gt;%let j=2;&lt;BR /&gt;%let shortID=%qscan(%superQ(Patients),&amp;amp;j.);*the patient ID of the jth patient from the Patients list;&lt;BR /&gt;filename wear "/data/work/sasusers/jxs004/GingerYang/ReAct/data/original data from ReAct/Actigraph New/&amp;amp;shortID./&amp;amp;shortID. scoring with sleep.xlsx";&lt;BR /&gt;PROC IMPORT OUT=wear&amp;amp;shortID. DATAFILE=wear DBMS=xlsx REPLACE; SHEET="Daily"; GETNAMES=YES;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(2)method2:&lt;/P&gt;
&lt;P&gt;%let shortID=003;&lt;BR /&gt;filename wear "/data/work/sasusers/jxs004/GingerYang/ReAct/data/original data from ReAct/Actigraph New/&amp;amp;shortID./&amp;amp;shortID. scoring with sleep.xlsx";&lt;BR /&gt;PROC IMPORT OUT=wear&amp;amp;shortID. DATAFILE=wear DBMS=xlsx REPLACE; SHEET="Daily"; GETNAMES=YES;RUN;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 19:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584328#M166404</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-27T19:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584329#M166405</link>
      <description>&lt;P&gt;the information in log:&lt;/P&gt;&lt;P&gt;23 options symbolgen mlogic mprint;&lt;BR /&gt;24 %let patients=002 003 004;&lt;BR /&gt;25 %let j=2;&lt;BR /&gt;26 %let shortID=%qscan(%superQ(Patients),&amp;amp;j.);*the patient ID of the jth patient from the Patients list;&lt;BR /&gt;SYMBOLGEN: Macro variable J resolves to 2&lt;BR /&gt;27 filename wear "/data/work/sasusers/jxs004/GingerYang/ReAct/data/original data from ReAct/Actigraph&lt;BR /&gt;27 ! New/&amp;amp;shortID./&amp;amp;shortID. scoring with sleep.xlsx";&lt;BR /&gt;SYMBOLGEN: Macro variable SHORTID resolves to 003&lt;BR /&gt;SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.&lt;BR /&gt;SYMBOLGEN: Macro variable SHORTID resolves to 003&lt;BR /&gt;SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;28 PROC IMPORT OUT=wear&amp;amp;shortID. DATAFILE=wear DBMS=xlsx REPLACE; SHEET="Daily"; GETNAMES=YES;RUN;&lt;BR /&gt;SYMBOLGEN: Macro variable SHORTID resolves to 003&lt;BR /&gt;SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.&lt;BR /&gt;NOTE: PROCEDURE IMPORT used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;BR /&gt;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: Line generated by the macro variable "SHORTID".&lt;BR /&gt;28 wear003&lt;BR /&gt;___&lt;BR /&gt;22&lt;BR /&gt;___&lt;BR /&gt;200&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATAFILE, DATATABLE, DBMS, DEBUG, FILE, OUT, REPLACE, TABLE,&lt;BR /&gt;_DEBUG_.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 19:06:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584329#M166405</guid>
      <dc:creator>JShi</dc:creator>
      <dc:date>2019-08-27T19:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584330#M166406</link>
      <description>&lt;P&gt;Please click on the {i} icon and paste your log into the window that appears.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 19:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584330#M166406</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-08-27T19:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584348#M166417</link>
      <description>&lt;P&gt;I suspect the macro quoting is causing problems.&amp;nbsp; It *should* work fine, but sometimes that macro quoting is not automatically removed like it should be.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let patients=002 003 004;
%let j=2;
%let shortID=%scan(&amp;amp;Patients,&amp;amp;j.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If it does, that would confirm it's a macro unquoting problem.&amp;nbsp; You could either avoid the macro quoting (as above) or explicitly %unquote the value with something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC IMPORT OUT=wear%unquote(&amp;amp;shortID)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Aug 2019 19:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584348#M166417</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2019-08-27T19:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584350#M166419</link>
      <description>&lt;P&gt;Don't quote strings unless they require quoting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The solution to your problem might be as simple as replacing %QSCAN with %SCAN.&amp;nbsp; Give it a try and see if that does the trick.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 19:58:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584350#M166419</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-08-27T19:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584361#M166428</link>
      <description>&lt;P&gt;Why all the quoting in&lt;/P&gt;
&lt;PRE&gt;%let shortID=%qscan(%superQ(Patients),&amp;amp;j.);*&lt;/PRE&gt;
&lt;P&gt;You are potentially introducing artifacts that aren't needed:&lt;/P&gt;
&lt;PRE&gt;%let shortid= %scan(&amp;amp;patients,&amp;amp;j.);
%put shortid=&amp;amp;shortid.;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Aug 2019 20:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/584361#M166428</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-27T20:27:06Z</dc:date>
    </item>
  </channel>
</rss>

