<?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: Splitting a string variable and printing it into a PDF in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-string-variable-and-printing-it-into-a-PDF/m-p/875963#M346108</link>
    <description>&lt;P&gt;I have re-confirmed that the code I wrote works properly. The code you show includes code that you have changed from my code. Why did you change my code (other than the filename= in my code, which has to be different on my computer)? What is wrong with using the code EXACTLY as I wrote it (other than filename= )?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, please read the log carefully (&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 2&lt;/A&gt;) when your code doesn't work. It says:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Variable Info_2 is uninitialized.
&lt;/PRE&gt;
&lt;P&gt;so you are trying to work with a variable named Info_2 which does not exist.&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2023 10:53:56 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-05-16T10:53:56Z</dc:date>
    <item>
      <title>Splitting a string variable and printing it into a PDF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-string-variable-and-printing-it-into-a-PDF/m-p/874942#M345705</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;
&lt;P&gt;I am trying to split a string variable by its delimiter and printing the whole thing into 2 different SAS tables on 2 Pages as a PDF. Here is some example data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata;&lt;BR /&gt;length Info1 $20 Info2 $100;&lt;BR /&gt;Info1 = "Content";&lt;BR /&gt;Info2 = "Houses in Germany; Houses in Turkey";&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So far, I have tried to split the Info2 Variable by a semicolon like that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let x = 1;

ods pdf file="J:\Allgemein\Skalendoku23\Ordnerstruktur SkaD\E\Skalendoku.pdf";
ods pdf startpage=now;
ods layout start;

data want;
  set mydata;
    Item = scan(Info2, &amp;amp;x, ";");
run;

proc report data=want;
run;
ods pdf startpage=now;

ods pdf close;
ods layout end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The code above produces a table with a new variable called "item" and stores the second string behind the semicolon (= Houses in Turkey) in it. Unfortunately, I am struggling with implementing that logic into a DO-Loop so that I would generate 2 Pages in a PDF Document, where the result should look like that on Page 1:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jakobsen96_0-1683725805539.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83809i30B9EF47CDC5DECB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jakobsen96_0-1683725805539.png" alt="Jakobsen96_0-1683725805539.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and like that on Page 2:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jakobsen96_1-1683725828624.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83810iFF7DB6931CA9407F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jakobsen96_1-1683725828624.png" alt="Jakobsen96_1-1683725828624.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Is it possible to create some kind of DO-Loop that extracts the wanted string out of the info2 column and write it into a separate table at once? As I want to do that for about 200 different Items (lets say "countries"), I thought about creating a macrovariable that stores all countries and produces 200 tables (which would equal 200 Pages in the PDF Document); one for each country. The Information in Info1 (= Content) should stay the same. I am happy for any advice!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 13:42:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-string-variable-and-printing-it-into-a-PDF/m-p/874942#M345705</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2023-05-10T13:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a string variable and printing it into a PDF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-string-variable-and-printing-it-into-a-PDF/m-p/874955#M345711</link>
      <description>&lt;P&gt;You need a loop inside a macro to create the PDF. However, you only want ODS PDF FILE= once (in other words not in the loop) and you only want ODS PDF CLOSE once (in other words not in the loop).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro do_this;
    ods pdf file="Skalendoku.pdf";
    %do x = 1 %to 2;
        ods pdf startpage=now;
        data want;
            set mydata;
            Item = scan(Info2, &amp;amp;x, ";");
        run;

        proc report data=want;
        run;
    %end;
    ods pdf close;
%mend;
%do_this&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you say&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Is it possible to create some kind of DO-Loop that extracts the wanted string out of the info2 column and write it into a separate table at once? As I want to do that for about 200 different Items (lets say "countries"), I thought about creating a macrovariable that stores all countries and produces 200 tables (which would equal 200 Pages in the PDF Document); one for each country. The Information in Info1 (= Content) should stay the same. I am happy for any advice!&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am not sure I can derive any meaning from this, nor do I see how this corresponds to the example you have presented. Instead of talking about macro variables, just explain the input and explain the desired output (don't try to explain the code).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 14:25:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-string-variable-and-printing-it-into-a-PDF/m-p/874955#M345711</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-10T14:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a string variable and printing it into a PDF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-string-variable-and-printing-it-into-a-PDF/m-p/875949#M346105</link>
      <description>&lt;P&gt;Hey, thank you for your reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as I understood you correctly my code should now look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata;
  length Info1 $20 Info2 $100;
  Info1 = "Content";
  Info2 = "Houses in Germany; Houses in Turkey";
  output;
run;


%macro do_this;
data have;
set mydata;
run;

ods pdf file="J:\Allgemein\Skalendoku23\Ordnerstruktur SkaD\E\Test.pdf";
%do x = 1 %to 2;

ods pdf startpage=now;
ods layout start;

data want;
  set have;
    Item = scan(Info_2, &amp;amp;x, ";");
run;

proc report data=want;
run;

%end;

ods pdf close;
ods layout end;

%mend do_this;
%do_this;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I agree that my explanation about macrovariables is not quite understandable and I think it will be enough if I understand how to do the macro correctly. Unfortunately, with the code above I now create a PDF that looks like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jakobsen96_0-1684229265673.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84004i1B8ABA6AC3B87E32/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jakobsen96_0-1684229265673.png" alt="Jakobsen96_0-1684229265673.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get one page out of the code which is quite confusing to me as I would have thought that the macro should generate 2 pages atleast due to the do-loop. To me the code looks like it should do what its supposed to, but obviously it does not. However, I am still not getting 2 pages out and it does not read the information out of my data and writes it into separate tables (as in my original question). Do you know where I went wrong?&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 09:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-string-variable-and-printing-it-into-a-PDF/m-p/875949#M346105</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2023-05-16T09:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a string variable and printing it into a PDF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-string-variable-and-printing-it-into-a-PDF/m-p/875963#M346108</link>
      <description>&lt;P&gt;I have re-confirmed that the code I wrote works properly. The code you show includes code that you have changed from my code. Why did you change my code (other than the filename= in my code, which has to be different on my computer)? What is wrong with using the code EXACTLY as I wrote it (other than filename= )?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, please read the log carefully (&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 2&lt;/A&gt;) when your code doesn't work. It says:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Variable Info_2 is uninitialized.
&lt;/PRE&gt;
&lt;P&gt;so you are trying to work with a variable named Info_2 which does not exist.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 10:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-string-variable-and-printing-it-into-a-PDF/m-p/875963#M346108</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-16T10:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a string variable and printing it into a PDF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-string-variable-and-printing-it-into-a-PDF/m-p/875996#M346124</link>
      <description>&lt;P&gt;Alright, thank you! I have overseen the Info_2 message and thanks for the maxim link. Furthermore, I would have liked to work with the ods layout command but apparently that will stop SAS from generating 2 pages. Anyway, thank you for your time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 13:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-string-variable-and-printing-it-into-a-PDF/m-p/875996#M346124</guid>
      <dc:creator>_Manhattan</dc:creator>
      <dc:date>2023-05-16T13:33:49Z</dc:date>
    </item>
  </channel>
</rss>

