<?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 Convert a string to a category in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350572#M6912</link>
    <description>&lt;P&gt;Hello. &amp;nbsp;I am using SAS Visual Analytics 7.3 and I am currently using multiple if-then-else statements along with parameter values to return the appropriate category in a bar chart. &amp;nbsp;The syntax I am using is like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF ( ( 'ATD Cohort Year'p = '2012' ) AND ( 'End Term'p = '201214' ) )&lt;BR /&gt;RETURN 'ATD_2012_2014'n&lt;BR /&gt;ELSE IF ( ( 'ATD Cohort Year'p = '2012' ) AND ( 'End Term'p = '201216' ) )&lt;BR /&gt;RETURN 'ATD_2012_2016'n&lt;BR /&gt;ELSE ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is that there are many more combinations of "Cohort Year" and "End Term" than what I showed in the code above and I would like to simplify my code. &amp;nbsp;I am hopeful that I can use the concatenation operator to write a single if-then-else statement but I cannot figure out a way to make SAS VA interpret the string as a category. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code block creates the string "ATD_201212_201214" (when using a parameter value of 2012 for ATD Cohort Year&amp;nbsp;and 201214 for End Term), which is the name of the category I want to display. &amp;nbsp;SAS VA does not interpret this string as a category, however, and nothing is returned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF ( ( 'ATD Cohort Year'p NotMissing ) AND ( 'End Term'p NotMissing ) )&lt;BR /&gt;RETURN Concatenate(Concatenate('ATD_', Concatenate('ATD Cohort Year'p, '12_')), 'End Term'p)&lt;BR /&gt;ELSE ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code attempt below was to make the concatenations "look" like 'ATD_2012_2014'n &lt;SPAN&gt;(when using a parameter value of 2012 for &lt;/SPAN&gt;&lt;SPAN&gt;ATD Cohort Year&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;and 201214 for End Term) &amp;nbsp;&lt;/SPAN&gt;in another attempt to get SAS VA to interpret the string as a category. &amp;nbsp;The backslashes are used to escape the single quote inside the pair of single quotes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF ( ( 'ATD Cohort Year'p NotMissing ) AND ( 'End Term'p NotMissing ) )&lt;BR /&gt;RETURN Concatenate(Concatenate(Concatenate('\'ATD_', Concatenate('ATD Cohort Year'p, '12_')), 'End Term'p),'\'n')&lt;BR /&gt;ELSE ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to cobble together strings to create a calculated category in SAS VA? &amp;nbsp;If not, is there another way to achieve the result that I want without writing dozens of if-then-else statements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Apr 2017 17:21:27 GMT</pubDate>
    <dc:creator>Coop</dc:creator>
    <dc:date>2017-04-17T17:21:27Z</dc:date>
    <item>
      <title>Convert a string to a category</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350572#M6912</link>
      <description>&lt;P&gt;Hello. &amp;nbsp;I am using SAS Visual Analytics 7.3 and I am currently using multiple if-then-else statements along with parameter values to return the appropriate category in a bar chart. &amp;nbsp;The syntax I am using is like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF ( ( 'ATD Cohort Year'p = '2012' ) AND ( 'End Term'p = '201214' ) )&lt;BR /&gt;RETURN 'ATD_2012_2014'n&lt;BR /&gt;ELSE IF ( ( 'ATD Cohort Year'p = '2012' ) AND ( 'End Term'p = '201216' ) )&lt;BR /&gt;RETURN 'ATD_2012_2016'n&lt;BR /&gt;ELSE ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is that there are many more combinations of "Cohort Year" and "End Term" than what I showed in the code above and I would like to simplify my code. &amp;nbsp;I am hopeful that I can use the concatenation operator to write a single if-then-else statement but I cannot figure out a way to make SAS VA interpret the string as a category. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code block creates the string "ATD_201212_201214" (when using a parameter value of 2012 for ATD Cohort Year&amp;nbsp;and 201214 for End Term), which is the name of the category I want to display. &amp;nbsp;SAS VA does not interpret this string as a category, however, and nothing is returned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF ( ( 'ATD Cohort Year'p NotMissing ) AND ( 'End Term'p NotMissing ) )&lt;BR /&gt;RETURN Concatenate(Concatenate('ATD_', Concatenate('ATD Cohort Year'p, '12_')), 'End Term'p)&lt;BR /&gt;ELSE ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code attempt below was to make the concatenations "look" like 'ATD_2012_2014'n &lt;SPAN&gt;(when using a parameter value of 2012 for &lt;/SPAN&gt;&lt;SPAN&gt;ATD Cohort Year&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;and 201214 for End Term) &amp;nbsp;&lt;/SPAN&gt;in another attempt to get SAS VA to interpret the string as a category. &amp;nbsp;The backslashes are used to escape the single quote inside the pair of single quotes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF ( ( 'ATD Cohort Year'p NotMissing ) AND ( 'End Term'p NotMissing ) )&lt;BR /&gt;RETURN Concatenate(Concatenate(Concatenate('\'ATD_', Concatenate('ATD Cohort Year'p, '12_')), 'End Term'p),'\'n')&lt;BR /&gt;ELSE ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to cobble together strings to create a calculated category in SAS VA? &amp;nbsp;If not, is there another way to achieve the result that I want without writing dozens of if-then-else statements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 17:21:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350572#M6912</guid>
      <dc:creator>Coop</dc:creator>
      <dc:date>2017-04-17T17:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a string to a category</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350625#M6913</link>
      <description>&lt;P&gt;Hi Coop,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm confused as to why your second expression doesn't work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;IF ( ( 'ATD Cohort Year'p NotMissing ) AND ( 'End Term'p NotMissing ) )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RETURN Concatenate(Concatenate('ATD_', Concatenate('ATD Cohort Year'p, '12_')), 'End Term'p)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ELSE ' '&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You say that it doesn't return a category. Is it possible one of your parameters is numeric instead of character?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sam&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 19:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350625#M6913</guid>
      <dc:creator>Sam_SAS</dc:creator>
      <dc:date>2017-04-17T19:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a string to a category</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350631#M6914</link>
      <description>&lt;P&gt;Hello Sam_SAS. &amp;nbsp;Thanks so much for responding. &amp;nbsp;Both of the parameters are character. &amp;nbsp;The concatenation of the parameters produces the correct string (ATD_201212_201214) but I believe that a string is all that SAS sees. &amp;nbsp;When I view&amp;nbsp;the preview of the calculated item, each row has the string ATD_201212_201214 instead of the contents of the ATD_201212_201214 that is already in the data set.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 20:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350631#M6914</guid>
      <dc:creator>Coop</dc:creator>
      <dc:date>2017-04-17T20:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a string to a category</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350634#M6915</link>
      <description>&lt;P&gt;Ohhhh now I get it, you want to return the value of a different category, depending on the conditions. Now your third expression makes sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried a very simple proof of concept here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RETURN Concatenate('Ag', 'e\'n')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where Age is a variable in my table, and i can't seem to get it to evaluate the value of Age instead of just returning "Age'n".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect this just cannot work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The good(?) news is, creating all of the individual conditions should work if you can stand the tedium to build the expression. You could make a script in Perl or whatever to generate the&amp;nbsp;syntax and then just paste it into the VA expression builder, if that helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps,&lt;/P&gt;
&lt;P&gt;Sam&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 20:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350634#M6915</guid>
      <dc:creator>Sam_SAS</dc:creator>
      <dc:date>2017-04-17T20:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a string to a category</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350636#M6916</link>
      <description>&lt;P&gt;Awww, sad. &amp;nbsp;Thanks for taking a look. &amp;nbsp;Making all the individual conditions isn't great but I thought it would be easier if I could make things more efficient. &amp;nbsp;After all, this probably won't be the last time I run into a situation like this. &amp;nbsp;I haven't thought of using another program to create the conditions. &amp;nbsp;Using a script may cut down on the chance of a typing error.&amp;nbsp; Thanks again.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 20:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350636#M6916</guid>
      <dc:creator>Coop</dc:creator>
      <dc:date>2017-04-17T20:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a string to a category</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350644#M6918</link>
      <description>&lt;P&gt;I'll confirm with the developers whether or not it is possible to specify a variable in this way. If it is not, we should create an "idea" (effectively, a feature request) for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Sam&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 21:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350644#M6918</guid>
      <dc:creator>Sam_SAS</dc:creator>
      <dc:date>2017-04-17T21:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a string to a category</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350812#M6923</link>
      <description>Excellent. Thanks so much.&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Apr 2017 12:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350812#M6923</guid>
      <dc:creator>Coop</dc:creator>
      <dc:date>2017-04-18T12:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a string to a category</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350873#M6925</link>
      <description>&lt;P&gt;Another approache might be to restructure your data.&amp;nbsp; So instead of having the additional measures, you simply have one&amp;nbsp;measure that represents all of the value.&amp;nbsp; You would then have a separate column that is the name of the string you are looking for (MyNewString).&amp;nbsp; So, you would build your bar chart with the same measure all of the time, but you would filter that measure based on the character value of another column.&amp;nbsp; You would then add a filter to the data similar to your other expression:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF ( ( 'ATD Cohort Year'p NotMissing ) AND ( 'End Term'p NotMissing ) )&lt;BR /&gt;RETURN "MyNewString"n = Concatenate(Concatenate('ATD_', Concatenate('ATD Cohort Year'p, '12_')), 'End Term'p)&lt;BR /&gt;ELSE 1 = 0&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 14:30:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350873#M6925</guid>
      <dc:creator>KeithM</dc:creator>
      <dc:date>2017-04-18T14:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a string to a category</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350941#M6926</link>
      <description>I confirmed with the developers that it is not possible currently. I think to make it work they might need to create a new operator specifically for the purpose, but that is not out of the question.&lt;BR /&gt;&lt;BR /&gt;Can you go here:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas/label-name/sas%20visual%20analytics" target="_blank"&gt;https://communities.sas.com/t5/SASware-Ballot-Ideas/idb-p/sas_ideas/label-name/sas%20visual%20analytics&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and create an "idea"?&lt;BR /&gt;&lt;BR /&gt;What you would label such an idea is sort of tricky. Something like, "Enable dynamic variable references in expression syntax"?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sam</description>
      <pubDate>Tue, 18 Apr 2017 17:22:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350941#M6926</guid>
      <dc:creator>Sam_SAS</dc:creator>
      <dc:date>2017-04-18T17:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a string to a category</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350966#M6930</link>
      <description>&lt;P&gt;Thanks for your thoughts Keith.&amp;nbsp; It would take quite a bit of work to restructure my current dataset but that is something to think about with new datasets.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 18:39:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350966#M6930</guid>
      <dc:creator>Coop</dc:creator>
      <dc:date>2017-04-18T18:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a string to a category</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350980#M6931</link>
      <description>&lt;P&gt;Thanks Sam.&amp;nbsp; I did create an "idea" as you suggested and I used the idea name that you suggested.&amp;nbsp; I think this feature would be helpful for many.&amp;nbsp; Have a great day.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 18:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Convert-a-string-to-a-category/m-p/350980#M6931</guid>
      <dc:creator>Coop</dc:creator>
      <dc:date>2017-04-18T18:53:42Z</dc:date>
    </item>
  </channel>
</rss>

