<?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 how to create a format using string of a value using proc format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-format-using-string-of-a-value-using-proc-format/m-p/569268#M160401</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a format from a part of a string using scan function. I am getting errors. Please suggest.&amp;nbsp; Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let treat1=Placebo + chemotherapy / Placebo;

proc format;
    value pcrfmt
   1=scan(&amp;amp;treat1.,1,'/')||"Responder"
   2=scan(&amp;amp;treat1.,1,'/')||"Non-Responder"
   
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Jun 2019 20:08:40 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2019-06-26T20:08:40Z</dc:date>
    <item>
      <title>how to create a format using string of a value using proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-format-using-string-of-a-value-using-proc-format/m-p/569268#M160401</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a format from a part of a string using scan function. I am getting errors. Please suggest.&amp;nbsp; Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let treat1=Placebo + chemotherapy / Placebo;

proc format;
    value pcrfmt
   1=scan(&amp;amp;treat1.,1,'/')||"Responder"
   2=scan(&amp;amp;treat1.,1,'/')||"Non-Responder"
   
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Jun 2019 20:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-format-using-string-of-a-value-using-proc-format/m-p/569268#M160401</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2019-06-26T20:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a format using string of a value using proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-format-using-string-of-a-value-using-proc-format/m-p/569270#M160402</link>
      <description>&lt;P&gt;You cannot run data step code inside the middle of statement inside a PROC. You need to use macro code to generate text that SAS will see as code to be run.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  value pcrfmt
   1="%scan(&amp;amp;treat1.,1,/) Responder"
   2="%scan(&amp;amp;treat1.,2,/) Non-Responder"
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You probably do not want those spaces around the / in your TREAT1 macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let treat1=Placebo + chemotherapy/Placebo;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you cannot get rid of them then it might be better to pull the string out first and then use it in the formatted label.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let treat1=Placebo + chemotherapy / Placebo;
proc format;
  value pcrfmt
%let value=%scan(&amp;amp;treat1.,1,/);
   1="&amp;amp;value. Responder"
%let value=%scan(&amp;amp;treat1.,2,/);
   2="&amp;amp;value. Non-Responder"
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 20:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-format-using-string-of-a-value-using-proc-format/m-p/569270#M160402</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-26T20:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a format using string of a value using proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-format-using-string-of-a-value-using-proc-format/m-p/569272#M160403</link>
      <description>I would suggest creating a format using a data set and then using CNTLIN within PROC FORMAT. There's a paper called not just another pretty face - proc format that's a great reference for understanding how to create a format. &lt;BR /&gt;Otherwise you could consider having a partial format. &lt;BR /&gt;&lt;BR /&gt;If you really want that to work, use %SCAN() or wrap it in %SYSFUNC()</description>
      <pubDate>Wed, 26 Jun 2019 20:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-format-using-string-of-a-value-using-proc-format/m-p/569272#M160403</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-26T20:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to create a format using string of a value using proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-format-using-string-of-a-value-using-proc-format/m-p/569282#M160408</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/68272"&gt;@knveraraju91&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a format from a part of a string using scan function. I am getting errors. Please suggest.&amp;nbsp; Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let treat1=Placebo + chemotherapy / Placebo;

proc format;
    value pcrfmt
   1=scan(&amp;amp;treat1.,1,'/')||"Responder"
   2=scan(&amp;amp;treat1.,1,'/')||"Non-Responder"
   
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;May I ask why you need macro code to build this? If the values "Placebo" and "chemotherapy" are&amp;nbsp;coming from somewhere that you aren't sure&amp;nbsp;what they may be and used to create Treat1 perhaps describing that would be the place to start. Is there a list or something that holds the corresponding "responder" and "non-responder" somewhere? Otherwise this appears way more overkill than is warranted by this example.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 20:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-create-a-format-using-string-of-a-value-using-proc-format/m-p/569282#M160408</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-26T20:51:11Z</dc:date>
    </item>
  </channel>
</rss>

