<?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: Don't quote input in custom transformation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/558235#M155782</link>
    <description>&lt;P&gt;%unquote() is the way to go in my experience.&lt;/P&gt;</description>
    <pubDate>Mon, 13 May 2019 09:04:28 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-05-13T09:04:28Z</dc:date>
    <item>
      <title>Don't quote input in custom transformation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/557748#M155535</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created a custom transformation inside of DI Studio and I'm using the input mask. When a string is entered into one of these fields %let var1 = %nrquote(input of user) is automatically entered but the coding below doesn't work with a quoted string instead it needs the unquoted one - safety concerns are not an issue here - is there an option which suppress %nrquote function or do I have to %let var1 = %unquote(&amp;amp;var1.)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Criptic&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2019 12:38:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/557748#M155535</guid>
      <dc:creator>Criptic</dc:creator>
      <dc:date>2019-05-10T12:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: Don't quote input in custom transformation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/557762#M155540</link>
      <description>&lt;P&gt;You will probably need to add your own logic to remove the macro quoting. I don't think DI has the smarts to know when it is safe to NOT add the macro quoting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the field is really being completed by users then you should also add some logic to check the value before blindly using it.&lt;/P&gt;
&lt;P&gt;Perhaps by getting out of macro world and into SAS code instead.&amp;nbsp; Although that might be harder in DI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example if the value is supposed to be string that is assigned to a character variable you can use the SYMGET() function&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;myvar = sysget('myPrompt');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;instead of expanding the macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;myvar ="&amp;amp;myPrompt";
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to prevent strings with unbalanced quotes from breaking your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if the value is intended to be used as a variable name then use NVALID() or NLITERAL() function to test it or fix it up before using it.&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2019 13:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/557762#M155540</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-10T13:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Don't quote input in custom transformation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/557815#M155556</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&amp;amp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/50279"&gt;@Criptic&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What sort of input do you expect? - the %nrquote function does not add quotes, it only masks the string, so the macro compiler ignores &amp;amp; and % in the string and does not try to resolve variables.&amp;nbsp; But using these characters in the string will give a warning in DI Studio before execution of the supplied code. If the string is just plain text without &amp;amp; or %, the&amp;nbsp;%nrquote function does not make any difference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I made a small example transformation, and here is a snippet of the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;110        
111        %let myinput = %nrquote(This is ' a &amp;amp;text);
WARNING: Apparent symbolic reference TEXT not resolved.
112        
113        /* Code supplied to User Transformation */
114        
115        %put &amp;amp;=myinput;
MYINPUT=This is ' a &amp;amp;text
116        
117        data _null_;
118        	a = "&amp;amp;myinput";
119        	put a=;
120        run;

a=This is ' a &amp;amp;text&lt;/PRE&gt;
&lt;P&gt;Execution of the DI Studio generated code %let myinput = %nrquote((This is a &amp;amp;text); gives a warning, but thanks to the masking function &amp;amp;text is not resolved, so &amp;amp;myinput contains the string supplied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It can be used in macro code without problem, as you see in the line written by&amp;nbsp;%put &amp;amp;=myinput;&lt;/P&gt;
&lt;P&gt;And it can be used in a data step by adding quotes where you refer to it, just like "normal" macro variables, so there is no need for symget functions, as you can see working in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you don't need any special precautions to cope with unbalanced quotes, as you see in the example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This also shows that it is not hard to use data steps in a DI Studio User Transformation.&amp;nbsp;&lt;SPAN&gt;The User Transformation is a container for SAS code, and a&lt;/SPAN&gt;&lt;SPAN&gt;ny program that works in a SAS Display Manager session will also work in a User Transformation. The code&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;can contain any numbers of Proc- and Data steps and macro code, so a Data _NULL_ step to evaluate and maniputate user input can safely be added as a first step in the code.&lt;/SPAN&gt;&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, 10 May 2019 15:12:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/557815#M155556</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-05-10T15:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Don't quote input in custom transformation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/558215#M155775</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12887"&gt;@ErikLund_Jensen&lt;/a&gt;&amp;nbsp; for your answers:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The input I expect is the name of a column, a lib name, a table name and a cube name. The Transformation auto generates MDX for the cube based on the column names and values. The thing is I have a proc sql in there in the form of:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table work.step_1 as
select distinct &amp;amp;col.
from &amp;amp;lib..&amp;amp;table.;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now if the input gets put through the %nrquote function it won't work anymore. So what I'm doing now is I use %unquote and then it works again. I have no idea why it doesn't work with %nrquote but it doesn't. Following I created an example coding which doesn't run with the macro variables which where run through %nrquote:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let lib = sashelp;
%let table = class;
%let col = name;

proc sql;
create table work.aaa_&amp;amp;table. as
select &amp;amp;col. from &amp;amp;lib..&amp;amp;table.;
quit;


%let lib = %nrquote(sashelp);
%let table = %nrquote(class);
%let col = %nrquote(name);

proc sql;
create table work.aaa_&amp;amp;table. as
select &amp;amp;col. from &amp;amp;lib..&amp;amp;table.;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you unquote the value of the macro variable it works again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind Regards&lt;/P&gt;
&lt;P&gt;Criptic&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 07:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/558215#M155775</guid>
      <dc:creator>Criptic</dc:creator>
      <dc:date>2019-05-13T07:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Don't quote input in custom transformation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/558235#M155782</link>
      <description>&lt;P&gt;%unquote() is the way to go in my experience.&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 09:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/558235#M155782</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-13T09:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Don't quote input in custom transformation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/558237#M155783</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DIS is for development of ETL processes and they are always run in batch in a production environment without direct user input. The prompts are used for data driven parameter passing only.&lt;/P&gt;
&lt;P&gt;Even when running jobs out of the DIS client during development you'll never get a prompt for user input as you could using other clients like EG.&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 10:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/558237#M155783</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-13T10:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Don't quote input in custom transformation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/558243#M155787</link>
      <description>Yeah seems like my only solution, was just hoping somebody knew an option &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;</description>
      <pubDate>Mon, 13 May 2019 09:30:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Don-t-quote-input-in-custom-transformation/m-p/558243#M155787</guid>
      <dc:creator>Criptic</dc:creator>
      <dc:date>2019-05-13T09:30:17Z</dc:date>
    </item>
  </channel>
</rss>

