<?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: How to convert string to SAS text in one data step? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412668#M279866</link>
    <description>&lt;P&gt;The data step is compiled before execution. You cannot change the code while it executes.&lt;/P&gt;
&lt;P&gt;You can only execute already-written code conditionally with if-then-else or select()-when()-end.&lt;/P&gt;</description>
    <pubDate>Sun, 12 Nov 2017 08:07:17 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-11-12T08:07:17Z</dc:date>
    <item>
      <title>How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412547#M279854</link>
      <description>Guys, I want to achieve below goal, but I don't know how to convert string to SAS text, could someone help me please? Thanks in advance. for string, I mean, in data step, X="AAA" then X's value AAA is string. for SAS text, I mean, %let X=AAA, then AAA here is SAS text. purpose: for vars X1-XN, step1 exclude missing value, step2 check if X1=X2=...=XN is true for false (in below case, check X1=X2=X4) must be done in one data step; data in; X1=1; X2=1; X3=.; X4=1; run; %macro diff(vars=X1 X2 X3 X4); %let vars=%sysfunc(compbl(&amp;amp;vars)); %let count=%sysfunc(countw(&amp;amp;vars,' ')); data out; set in; length _CONN $100.; _CONN=''; %do i=1 %to &amp;amp;count; if missing(%scan(&amp;amp;vars,&amp;amp;i))=0 then _CONN=catx('=',_CONN,"%scan(&amp;amp;vars,&amp;amp;i)"); %end; call symputx('conn'||compress(_N_),_CONN); /*my problem is here, how to convert 【_CONN】 from string to SAS text?*/ /*symget('conn'||compress(_N_)) is string, not SAS text*/ if (symget('conn'||compress(_N_))) then JUDGE=1; else JUDGE=0; run; %mend; %diff;</description>
      <pubDate>Sat, 11 Nov 2017 06:12:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412547#M279854</guid>
      <dc:creator>caibird</dc:creator>
      <dc:date>2017-11-11T06:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412548#M279855</link>
      <description>&lt;P&gt;Please format your post. Also use a proper subwindow ("little running man" or {i} icon) to post code.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Nov 2017 06:26:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412548#M279855</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-11T06:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412550#M279856</link>
      <description>So you want to create/assign macro variables based on data step variable values?&lt;BR /&gt;CALL SYMPUT.</description>
      <pubDate>Sat, 11 Nov 2017 06:36:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412550#M279856</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-11-11T06:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412558#M279857</link>
      <description>data in; X1=1; X2=1; X3=.; X4=1; run; %macro diff(vars=X1 X2 X3 X4); %let vars=%sysfunc(compbl(&amp;amp;vars)); %let count=%sysfunc(countw(&amp;amp;vars,' ')); data out; set in; length _CONN $100.; _CONN=''; %do i=1 %to &amp;amp;count; if missing(%scan(&amp;amp;vars,&amp;amp;i))=0 then _CONN=catx('=',_CONN,"%scan(&amp;amp;vars,&amp;amp;i)"); %end; call symputx('conn'||compress(_N_),_CONN); /*my problem is here, how to convert 【_CONN】 from string to SAS text?*/ /*symget('conn'||compress(_N_)) is string, not SAS text*/ /*for string, I mean, in data step, X="AAA" then X's value AAA is string. */ /*for SAS text, I mean, %let X=AAA, then AAA is SAS text.*/ if (symget('conn'||compress(_N_))) then JUDGE=1; else JUDGE=0; run; %mend; %diff;</description>
      <pubDate>Sat, 11 Nov 2017 08:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412558#M279857</guid>
      <dc:creator>caibird</dc:creator>
      <dc:date>2017-11-11T08:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412559#M279858</link>
      <description>&lt;P&gt;&lt;STRONG&gt;PLEASE FORMAT YOUR CODE!!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Nov 2017 08:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412559#M279858</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-11T08:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412561#M279859</link>
      <description>sorry, don't know how to format. I see no button or something like that in my window. let me brief: In a data set have 4 columns A B C X. Column X="A=B=C" in all rows, I want to use "A=B=C" in below statement in same data step. if (A=B=C) then ... how to convert "A=B=C" to A=B=C? (one way is call symput('_X',X), but &amp;amp;_X cannot use in same data step)</description>
      <pubDate>Sat, 11 Nov 2017 08:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412561#M279859</guid>
      <dc:creator>caibird</dc:creator>
      <dc:date>2017-11-11T08:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412563#M279860</link>
      <description>&lt;P&gt;It's the 6th and 7th icons above the main posting window. Both preserve all formatting, the 7th (the "little running man") also provides enhanced-editor-like coloring.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Nov 2017 09:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412563#M279860</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-11T09:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412577#M279861</link>
      <description>&lt;P&gt;Mostly, the complications are from trying to get macro language to perform the functions of a DATA step.&amp;nbsp; Once you start a DATA step, following LENGTH CONN $ 100;, there should be no more macro language.&amp;nbsp; The DATA step can handle the calculations better than macro language could.&amp;nbsp; You might want a statement along these lines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array mylist {*} &amp;amp;vars;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But that would be the most macro language that the DATA step requires.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Nov 2017 11:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412577#M279861</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-11T11:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412579#M279862</link>
      <description>No no, the macro must be repeatable in same data step like below, the array cannot handle that. The function of mro is: after exclude missing vars. if var1=var2=...=varn then output the row,else no output. ************************* data in; X1=1; X2=1; X3=.; X4=1; Y1=2; Y2=4; Y3=17; Z1='A'; Z2='BC'; Z3='C'; Z4=''; ...; run; data out; set in; %mro(vars=X1 X2 X3 X4),out=); %mro(vars=Y1 Y2 Y3),out=); %mro(vars=Z1 Z2 Z3 Z4),out=); ...; run;</description>
      <pubDate>Sat, 11 Nov 2017 12:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412579#M279862</guid>
      <dc:creator>caibird</dc:creator>
      <dc:date>2017-11-11T12:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412581#M279863</link>
      <description>sorry, I see no icon at all on post window. There is only 3 tab: rich text, html, preview. And it takes 3min to open/refresh the web. But I visit other website normal. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;</description>
      <pubDate>Sat, 11 Nov 2017 12:15:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412581#M279863</guid>
      <dc:creator>caibird</dc:creator>
      <dc:date>2017-11-11T12:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412582#M279864</link>
      <description>&lt;P&gt;If you sketch out what the program should do, with no macro language involved, you will find ways to make a DATA step do what you ask.&amp;nbsp; For example, here are some possibilities:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if min(mylist{*}) = max(mylist{*}) then output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or possibly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do i=1 to dim(mylist);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if mylist{i} &amp;gt; ' ' then conn = catx(' ', conn, vname(mylist{i}));&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It starts with knowing the goal ... what is the DATA step that would work, if no macro language were involved.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Nov 2017 12:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412582#M279864</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-11T12:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412664#M279865</link>
      <description>thanks for reply. but actually my question is how to convert string to SAS text in same data step. I mean somehow I need to get a string like [A=B=C] from a data set's var, but then how to convert it to SAS text A=B=C so allow me to use if (A=B=C) then in the same data step.</description>
      <pubDate>Sun, 12 Nov 2017 07:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412664#M279865</guid>
      <dc:creator>caibird</dc:creator>
      <dc:date>2017-11-12T07:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412668#M279866</link>
      <description>&lt;P&gt;The data step is compiled before execution. You cannot change the code while it executes.&lt;/P&gt;
&lt;P&gt;You can only execute already-written code conditionally with if-then-else or select()-when()-end.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Nov 2017 08:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412668#M279866</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-12T08:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412722#M279867</link>
      <description>&lt;P&gt;You're still asking macro language to do something it can't.&amp;nbsp; It can't inspect the data, and adjust the program in the middle of the same DATA step.&amp;nbsp; But the DATA step can do that.&amp;nbsp; Here's the idea for one set of variables, where vars=X1 X2 X3 X4 that are assumed to be numeric just to simplify the initial version of the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;array test1 {*} &amp;amp;vars;&lt;/P&gt;
&lt;P&gt;if max(of test1{*}) = min(of test1{*}) then output;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The MIN and MAX functions ignore missing values, thus the IF/THEN statement automatically checks whether all nonmissing values are equal.&amp;nbsp; That might still be problematic since there might be only one nonmissing value remaining ... you would have to decide what is the right action in that case.&amp;nbsp; Do we still need to jump through hoops for sets of numeric variables?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this looks like it doesn't do the right thing, why not?&amp;nbsp; If this looks like a satisfactory result, we can talk about how to handle sets of character variables.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Nov 2017 20:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412722#M279867</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-12T20:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412967#M279868</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/92129"&gt;@caibird&lt;/a&gt; wrote:&lt;BR /&gt;sorry, don't know how to format. I see no button or something like that in my window. let me brief: In a data set have 4 columns A B C X. Column X="A=B=C" in all rows, I want to use "A=B=C" in below statement in same data step. if (A=B=C) then ... how to convert "A=B=C" to A=B=C? (one way is call symput('_X',X), but &amp;amp;_X cannot use in same data step)&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Below&amp;nbsp;where you see Rich Text HTML Preview, &lt;STRONG&gt;inside&lt;/STRONG&gt; the window you should see a row of images starting with &lt;STRONG&gt;B&lt;/STRONG&gt;. They are icons but are not buttons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'Format' in this instance means to make your code legible to people by using (generally) one line per statement or instruction, indenting code between any sort of start /end block (data/run, proc/run, do/end, Select/end) so that program flow can be seen and understood easier.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 17:28:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/412967#M279868</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-13T17:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert string to SAS text in one data step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/413216#M279869</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/92129"&gt;@caibird&lt;/a&gt; wrote:&lt;BR /&gt;sorry, I see no icon at all on post window. There is only 3 tab: rich text, html, preview. And it takes 3min to open/refresh the web. But I visit other website normal. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;See here:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="editor_icons.png"&gt;&lt;img src="https://communities.sas.com/skins/images/8D8B612AA6AB1DC7E9A0812281D56E02/responsive_peak/images/image_not_found.png" alt="editor_icons.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The active icon in this screenshot is the "little running man" icon, the next one to the left of it is the {i} icon.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 06:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-string-to-SAS-text-in-one-data-step/m-p/413216#M279869</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-14T06:52:16Z</dc:date>
    </item>
  </channel>
</rss>

