<?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 why my code does't work in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/why-my-code-does-t-work/m-p/473506#M121522</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;i am trying to create multiple table from a dataset , so in the data statement i have mentioned all those table name (macro variable table_name)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have pasted the log file which is showing some syntax error , please help me to resolve the issue&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;23         GOPTIONS ACCESSIBLE;
SYMBOLGEN:  Macro variable TABLE_NAME resolves to ATLANTA BRECKSVILLE CHICAGO CLEVELAND COLUMBUS DETROIT MIDDLEBRG_HTS MOUNT_VERNON 
            PHILA PHILADELPHIA SYLVANIA TOLEDO
24         data &amp;amp;table_name.;
25         set multiple_table;
26         do i=1 to &amp;amp;count.;
SYMBOLGEN:  Macro variable COUNT resolves to       12
27         if ProviderCity = cat('"',scan(&amp;amp;var_names.,i,","),'"') then output scan(&amp;amp;output_name.,i,",");
SYMBOLGEN:  Macro variable VAR_NAMES resolves to "ATLANTA,BRECKSVILLE,CHICAGO,CLEVELAND,COLUMBUS,DETROIT,MIDDLEBRG HTS,MOUNT 
            VERNON,PHILA,PHILADELPHIA,SYLVANIA,TOLEDO"
SYMBOLGEN:  Macro variable OUTPUT_NAME resolves to 
            "ATLANTA,BRECKSVILLE,CHICAGO,CLEVELAND,COLUMBUS,DETROIT,MIDDLEBRG_HTS,MOUNT_VERNON,PHILA,PHILADELPHIA,SYLVANIA,TOLEDO"
27         if ProviderCity = cat('"',scan(&amp;amp;var_names.,i,","),'"') then output scan(&amp;amp;output_name.,i,",");
                                                                                  _
                                                                                  22
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, RC, _DATA_, _LAST_, _NULL_.  

27         if ProviderCity = cat('"',scan(&amp;amp;var_names.,i,","),'"') then output scan(&amp;amp;output_name.,i,",");
                                                                                  _
                                                                                  76
ERROR 76-322: Syntax error, statement will be ignored.

28         end;
29         run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jun 2018 18:02:08 GMT</pubDate>
    <dc:creator>soham_sas</dc:creator>
    <dc:date>2018-06-26T18:02:08Z</dc:date>
    <item>
      <title>why my code does't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-my-code-does-t-work/m-p/473506#M121522</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;i am trying to create multiple table from a dataset , so in the data statement i have mentioned all those table name (macro variable table_name)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have pasted the log file which is showing some syntax error , please help me to resolve the issue&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;23         GOPTIONS ACCESSIBLE;
SYMBOLGEN:  Macro variable TABLE_NAME resolves to ATLANTA BRECKSVILLE CHICAGO CLEVELAND COLUMBUS DETROIT MIDDLEBRG_HTS MOUNT_VERNON 
            PHILA PHILADELPHIA SYLVANIA TOLEDO
24         data &amp;amp;table_name.;
25         set multiple_table;
26         do i=1 to &amp;amp;count.;
SYMBOLGEN:  Macro variable COUNT resolves to       12
27         if ProviderCity = cat('"',scan(&amp;amp;var_names.,i,","),'"') then output scan(&amp;amp;output_name.,i,",");
SYMBOLGEN:  Macro variable VAR_NAMES resolves to "ATLANTA,BRECKSVILLE,CHICAGO,CLEVELAND,COLUMBUS,DETROIT,MIDDLEBRG HTS,MOUNT 
            VERNON,PHILA,PHILADELPHIA,SYLVANIA,TOLEDO"
SYMBOLGEN:  Macro variable OUTPUT_NAME resolves to 
            "ATLANTA,BRECKSVILLE,CHICAGO,CLEVELAND,COLUMBUS,DETROIT,MIDDLEBRG_HTS,MOUNT_VERNON,PHILA,PHILADELPHIA,SYLVANIA,TOLEDO"
27         if ProviderCity = cat('"',scan(&amp;amp;var_names.,i,","),'"') then output scan(&amp;amp;output_name.,i,",");
                                                                                  _
                                                                                  22
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, RC, _DATA_, _LAST_, _NULL_.  

27         if ProviderCity = cat('"',scan(&amp;amp;var_names.,i,","),'"') then output scan(&amp;amp;output_name.,i,",");
                                                                                  _
                                                                                  76
ERROR 76-322: Syntax error, statement will be ignored.

28         end;
29         run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 18:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-my-code-does-t-work/m-p/473506#M121522</guid>
      <dc:creator>soham_sas</dc:creator>
      <dc:date>2018-06-26T18:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: why my code does't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-my-code-does-t-work/m-p/473513#M121525</link>
      <description>&lt;P&gt;The OUTPUT statement doesn't allow an expression.&amp;nbsp; The name of the data set has to be hard-coded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would take some rework of your code to get this to work, but it can be done.&amp;nbsp; You would have to start to defining a macro and calling the macro, because you would need to change from SAS language DO to macro language %DO.&amp;nbsp; Along those lines, you could code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%macro make12;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%local k;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data &amp;amp;table_name.;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;set multiple_table;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%do k=1 %to &amp;amp;count;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; if ProviderCity = cat('"', scan(&amp;amp;var_names., &amp;amp;k, '",'), '"') &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; then output %scan(&amp;amp;output_name., &amp;amp;k, ",");&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%end;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%mend make12;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%make12&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 18:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-my-code-does-t-work/m-p/473513#M121525</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-26T18:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: why my code does't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-my-code-does-t-work/m-p/473516#M121526</link>
      <description>&lt;P&gt;A recurring question though is "Why do you want to split the data set?".&lt;/P&gt;
&lt;P&gt;A large number of things could be done with the existing set sorted by ProviderCity and then use BY ProviderCity to create summaries, reports or models based on the data for each city.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course I also consider use of only a City a dangerous thing as many cities have duplicated names in other states.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 22:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-my-code-does-t-work/m-p/473516#M121526</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-26T22:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: why my code does't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-my-code-does-t-work/m-p/473517#M121527</link>
      <description>&lt;P&gt;The output statement needs a dataset name as its argument. As that dataset is determined at compile time, you can't use an expression there.&lt;/P&gt;
&lt;P&gt;Note that by-group processing in data and procedure steps makes splitting of datasets for further processing unnecessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to split data for other reasons (like sending data to regional datamarts), you will need macro processing:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro split_data;
data &amp;amp;table_name;
set multiple_table;
%do i = 1 %to &amp;amp;count;
if provider_city = "%scan(&amp;amp;table_name,&amp;amp;i)" then output %scan(&amp;amp;table_name,&amp;amp;i);
%end;
run;
%mend;
%split_data&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will create &amp;amp;count if-then statements.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 18:46:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-my-code-does-t-work/m-p/473517#M121527</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-26T18:46:14Z</dc:date>
    </item>
  </channel>
</rss>

