<?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: issue with %scan in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183655#M34898</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Its new for me, its working&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Sep 2014 12:29:19 GMT</pubDate>
    <dc:creator>Aman4SAS</dc:creator>
    <dc:date>2014-09-03T12:29:19Z</dc:date>
    <item>
      <title>issue with %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183648#M34891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%let x= South Dakota, XY|New Jersy, NJ|Minneapolis-St. Paul, MN|Arizona's, AZ&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to fetch all area one by one using&lt;/P&gt;&lt;P&gt;%macro area();&lt;/P&gt;&lt;P&gt;%do i= 1 %to 4;&lt;/P&gt;&lt;P&gt;%let area= %scan(&amp;amp;x,&amp;amp;i,%str(|));&lt;/P&gt;&lt;P&gt;%put &amp;amp;area;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%area;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can we do that without manipulating original string and get the area name as it is?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2014 09:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183648#M34891</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2014-09-03T09:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: issue with %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183649#M34892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, this works:&lt;/P&gt;&lt;P&gt;%let x= "South Dakota, XY|New Jersy, NJ|Minneapolis-St. Paul, MN|Arizona's, AZ";&lt;BR /&gt;%macro area();&lt;BR /&gt;&amp;nbsp; %do i= 1 %to 4;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let area=%qscan(&amp;amp;x,&amp;amp;i,|);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;area;&lt;BR /&gt;&amp;nbsp; %end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%area;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I would again advise not to do things this way.&amp;nbsp; Your going to end up with all kinds of issues, differing quotes, space limitations etc.&amp;nbsp; What is it your trying to achieve (inputs/outputs)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2014 09:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183649#M34892</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-09-03T09:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: issue with %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183650#M34893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes, i agree, &lt;/P&gt;&lt;P&gt;i am able to achieve my output after manipulation in string. but i m looking if there is any macro function with the help of that i can achieve my output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with ur code, i will get first and last area with double quote. which i dont want , actually i will not get becaz this list is being created&amp;nbsp; from a dataset.&lt;/P&gt;&lt;P&gt;is there anything else?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2014 09:55:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183650#M34893</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2014-09-03T09:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: issue with %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183651#M34894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the list is being created from a dataset, then why not just generate the code from that dataset and save yourself some headaches:&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length state $200.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile datalines dlm="¬";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input state $;&lt;BR /&gt;datalines;&lt;BR /&gt;South DakotaXY &lt;BR /&gt;New Jersy NJ&lt;BR /&gt;Minneapolis-St. Paul MN&lt;BR /&gt;Arizona's, AZ&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp; call execute('%put '||state||';');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even if your calling another macro with that:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('%some_macro ("'||strip(state)||'");');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;Far simpler than messing with lists and list processing in macro code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2014 10:21:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183651#M34894</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-09-03T10:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: issue with %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183652#M34895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My apology if i was not clear with my que.&lt;/P&gt;&lt;P&gt;Actually i have a 15yr time series data of 100's of area. &lt;/P&gt;&lt;P&gt;and i have a dataset AREA , &lt;/P&gt;&lt;P&gt;i will create a macro variable list of area with separated by "|"&lt;/P&gt;&lt;P&gt;then i will run a do loop to create many type of dashboard.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for that i need to fetch the each area one by one, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks .&lt;/P&gt;&lt;P&gt;* i m lack of knowledge with Call execute &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2014 10:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183652#M34895</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2014-09-03T10:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: issue with %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183653#M34896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Amand4SAS, please review the "by" usage or the way SAS-portal or SAS-VA is doing that. Times are changing.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2014 10:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183653#M34896</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-09-03T10:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: issue with %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183654#M34897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"Actually i have a 15yr time series data of 100's of area" - exactly why I suggest that macro lists are not a good idea.&amp;nbsp; You have a dataset AREA which contains one observation per area.&amp;nbsp; Use this to your advantage:&lt;/P&gt;&lt;P&gt;data _null_; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set AREA;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('%Create_Dashboard(Area="'||strip(area)||'");');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So instead of the create_dashboard() macro doing the loop itself you use the call execute statement to generate one macro call per observation in AREA, passing in area as the macro parameter.&amp;nbsp; The macro remains quite simple then, a report example:&lt;/P&gt;&lt;P&gt;%macro Create_Dashboard (Area=);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc report data=my_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where area="&amp;amp;AREA.";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; column ...;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; define ...;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%mend Create_Dashboard;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2014 12:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183654#M34897</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-09-03T12:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: issue with %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183655#M34898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Its new for me, its working&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2014 12:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183655#M34898</guid>
      <dc:creator>Aman4SAS</dc:creator>
      <dc:date>2014-09-03T12:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: issue with %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183656#M34899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No probs.&amp;nbsp; Glad it helped.&amp;nbsp; Once you understand that the datastep can be used like a loop then it removes the need for long macro strings and splitting those out.&amp;nbsp; The call execute (and there is also call sub in newer SAS editions) are quite powerful.&amp;nbsp; I use them a fair bit and generate whole programs from metadata - a few lines of code, and a table of metadata can write lots of code out.&amp;nbsp; For instance my code above could become:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set area;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc report data=my_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where area="'||strip(area)||'";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If for New Jersey NJ you only want vara and varb output; but varc for the others:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set area;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc report data=my_data; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where area="'||strip(area)||'";');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if area ne "New Jersey, NJ" then call execute(' column vara varb varc;...');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else call execute(' column vara varb; ...');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2014 12:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/issue-with-scan/m-p/183656#M34899</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-09-03T12:39:57Z</dc:date>
    </item>
  </channel>
</rss>

