<?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: Case when then go to in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792824#M32678</link>
    <description>&lt;P&gt;What kind of script?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA step?&lt;/P&gt;
&lt;P&gt;Macro?&lt;/P&gt;
&lt;P&gt;PROC SQL?&lt;BR /&gt;Something else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us your code so far.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jan 2022 12:23:04 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-01-27T12:23:04Z</dc:date>
    <item>
      <title>Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792823#M32677</link>
      <description>&lt;P&gt;Hi there&lt;/P&gt;
&lt;P&gt;How to I instruct my script to jump to a certain point in the script when a certain condition is met?&lt;/P&gt;
&lt;P&gt;e.g.&lt;/P&gt;
&lt;P&gt;case when count is 0 then goto section1&lt;/P&gt;
&lt;P&gt;case when count is 1 then goto section4&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 12:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792823#M32677</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2022-01-27T12:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792824#M32678</link>
      <description>&lt;P&gt;What kind of script?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA step?&lt;/P&gt;
&lt;P&gt;Macro?&lt;/P&gt;
&lt;P&gt;PROC SQL?&lt;BR /&gt;Something else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us your code so far.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 12:23:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792824#M32678</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-27T12:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792825#M32679</link>
      <description>&lt;P&gt;You could try %goto macro statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro myCode(count);
%put *** START ***;

%if &amp;amp;count. = 0 %then %goto section1;
%if &amp;amp;count. = 1 %then %goto section4;

%section1:

  data _when_count_is_0;
    x=17;
  run;

%goto theend;

%section4:

  data _when_count_is_1;
    x=42;
  run;

%goto theend;

%theend:
%put *** END ***;
%mend;


%myCode(0)

%myCode(1)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 12:24:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792825#M32679</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-01-27T12:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792826#M32680</link>
      <description>How do I do it with both a Datastep option and a proc sql option?</description>
      <pubDate>Thu, 27 Jan 2022 12:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792826#M32680</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2022-01-27T12:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792828#M32681</link>
      <description>&lt;P&gt;SQL is the &lt;STRONG&gt;Structured&lt;/STRONG&gt; Query Language and does not have the concept of jumping around in the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As already asked, please supply examples for code where you think you need the GO TO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can tell you from my experience that I have coded more than 2 decades in SAS (quite successfully, I might say) without ever needing a GO TO.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 12:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792828#M32681</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-27T12:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792882#M32687</link>
      <description>I tried your code and it works great but when putting it in my code shared below I get this error:&lt;BR /&gt;ERROR: Expected %DO not found.&lt;BR /&gt;ERROR: Skipping to next %END statement.&lt;BR /&gt;&lt;BR /&gt;code:&lt;BR /&gt;&lt;BR /&gt;%if &amp;amp;filecount. = 0 %then %goto section1;&lt;BR /&gt;%if &amp;amp;filecount. = 1 %then %goto section2;&lt;BR /&gt;&lt;BR /&gt;%section1:&lt;BR /&gt; data _when_count_is_0;&lt;BR /&gt;    x=17;&lt;BR /&gt;  run;&lt;BR /&gt;&lt;BR /&gt;%goto theend;&lt;BR /&gt;&lt;BR /&gt;%theend:&lt;BR /&gt;%put *** END ***;&lt;BR /&gt;%mend;</description>
      <pubDate>Thu, 27 Jan 2022 15:23:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792882#M32687</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2022-01-27T15:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792891#M32690</link>
      <description>&lt;P&gt;Please show the whole macro code, from %MACRO to %MEND, and also include the macro call that results in the problem.&lt;/P&gt;
&lt;P&gt;Use the "little running man" button right next to the one indicated to post SAS code:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The subwindow will keep all the code formatting with a fixed-space font, and it will provide coloring similar to the Enhanced Editor that SAS on Windows and the Enterprise Guide use.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 15:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792891#M32690</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-27T15:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792911#M32697</link>
      <description>&lt;P&gt;From the code you shared I can't see what's the issue. Please do as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote and share more of your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 16:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/792911#M32697</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-01-27T16:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/793069#M32732</link>
      <description>%include "C:/list_files.sas";&lt;BR /&gt;&lt;BR /&gt;%let path_in=C:/FileCheck;&lt;BR /&gt;&lt;BR /&gt;/*List of files*/&lt;BR /&gt;%list_files("C:/Files",txt)&lt;BR /&gt;&lt;BR /&gt;%let filecount = 0;&lt;BR /&gt;&lt;BR /&gt;%if %sysfunc(exist(tables))&lt;BR /&gt;%then %do;&lt;BR /&gt;/*Count number of files*/&lt;BR /&gt;proc sql;&lt;BR /&gt;create table filecount as&lt;BR /&gt;select count(name) into: filecount &lt;BR /&gt;from tables;&lt;BR /&gt;quit;&lt;BR /&gt;%end;&lt;BR /&gt;&lt;BR /&gt;%if &amp;amp;filecount. = 0 %then %goto section3;&lt;BR /&gt;%if &amp;amp;filecount. = 1 %then %goto section2;&lt;BR /&gt;&lt;BR /&gt;%section3:&lt;BR /&gt; data _when_count_is_0;&lt;BR /&gt;    x=17;&lt;BR /&gt;  run;&lt;BR /&gt;&lt;BR /&gt;%goto theend;&lt;BR /&gt;&lt;BR /&gt;%theend:&lt;BR /&gt;%put *** END ***;&lt;BR /&gt;%mend;</description>
      <pubDate>Fri, 28 Jan 2022 06:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/793069#M32732</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2022-01-28T06:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/793072#M32734</link>
      <description>&lt;P&gt;1) You did very basic error, your code doesn't have the macro head:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macr yourMacroName(parameters...);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2) with such a definition you need to use a macro call after defining it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%yourMacroName(parameters...)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;3) With your example it look like you don't need the %GOTO "cannon", the regular conditional %IF will do the job.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code modified, with changes pointed by "arrows"&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include "C:/list_files.sas";

%let path_in=C:/FileCheck;

/*List of files*/
%list_files("C:/Files",txt)


%macro test(); /* &amp;lt;- macro head */

%let filecount = 0;
%if %sysfunc(exist(tables))
  %then %do;
  /*Count number of files*/
    proc sql;
      create table filecount as
      select count(name) into: filecount
      from tables;
    quit;
  %end;

%if &amp;amp;filecount. = 0 %then     /* &amp;lt;- replace GOTO with IF condition */
  %do;
    data _when_count_is_0;
      x=17;
    run;
  %end;


%mend;

%test()  /* &amp;lt;- call the macro */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 06:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/793072#M32734</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-01-28T06:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/793074#M32735</link>
      <description>&lt;P&gt;I tried but getting this error:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Citrine10_0-1643353963090.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67947i277097B904D36856/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Citrine10_0-1643353963090.png" alt="Citrine10_0-1643353963090.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 07:12:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/793074#M32735</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2022-01-28T07:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: Case when then go to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/793081#M32736</link>
      <description>&lt;P&gt;... where you get this... show us a meaningful part of the log...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S. from what I know about such situations you may have somewhere in your code a letter/symbol standing just after a quote symbol, like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put "some text"a_letter;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Jan 2022 08:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-when-then-go-to/m-p/793081#M32736</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-01-28T08:37:18Z</dc:date>
    </item>
  </channel>
</rss>

