<?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: string variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/string-variable/m-p/675131#M203365</link>
    <description>&lt;P&gt;1) All given tree codes seem to be numeric. I assume this is the real situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; in case some tree codes may be alphanumeric just change the type.&lt;/P&gt;
&lt;P&gt;2) The alternative logic is to have the tree codes as a dataset and merge it with your HAVE dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tree_codes;
   infile cards;
   input tree_type;  /* add $ for char type */
cards;
999 
888 
777 
444 
.....
; run;
proc sort data=tree_codes; by tree_type; run;
proc sort data=have; by tree_type; run;

data want;
merge have (in=in1)
          tree_codes(in=in2);
  by tree_type;
      if in1 and in2 then tree_type=1;
run;
proc print data=want(where=(tree_type=1));
var id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 06 Aug 2020 20:35:15 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2020-08-06T20:35:15Z</dc:date>
    <item>
      <title>string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-variable/m-p/675124#M203360</link>
      <description>&lt;P&gt;&lt;FONT color="#808000"&gt;*I used %nrstr to simplify the following check and it worked. I checked here if the tree_types falls under any of the following:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808000"&gt;'999', '888', '777', '444', '555', '666', '124', '543', '567', '987', '342', '123', '678', '876', '123', '432',&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808000"&gt;'657', '453', '125', '665', '776', '887', '567'. If it falls under any of these types then it is flagged&amp;nbsp;as '1'.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808000"&gt;&lt;FONT color="#000080"&gt;%let tree&lt;/FONT&gt; = &lt;FONT color="#000080"&gt;%nrstr&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;('999', '888', '777', '444', '555', '666', '124', '543', '567', '987', '342', '123', '678', '876', '123', &lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;'432', '657', '453', '125', '665', '776', '887', '567');&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;data&lt;/FONT&gt; &lt;/STRONG&gt;want;&lt;BR /&gt;&lt;FONT color="#000080"&gt;set&lt;/FONT&gt; have;&lt;BR /&gt;&lt;FONT color="#000080"&gt;if&lt;/FONT&gt; tree_type in (&amp;amp;tree) &lt;FONT color="#000080"&gt;then &lt;/FONT&gt;tree_type=&lt;FONT color="#000080"&gt;&lt;FONT color="#008000"&gt;1&lt;/FONT&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#000080"&gt;run;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;proc print &lt;/STRONG&gt;data&lt;/FONT&gt;=want;&lt;BR /&gt;&lt;FONT color="#000080"&gt;where&lt;/FONT&gt; tree_type in (&lt;FONT color="#008000"&gt;1&lt;/FONT&gt;);&lt;BR /&gt;&lt;FONT color="#003366"&gt;var&lt;/FONT&gt; id;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#003366"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000"&gt;*Now I am thinking&amp;nbsp;what is the alternative if I want to check many strings in one check like this. Such as in place of &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;('999', '888', '777', '444', '555', '666', '124', '543', '567', '987', '342', '123', '678', '876', '123', '432',&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;'657', '453', '125', '665', '776', '887', '567') there will be strings such as ('sbc', 'THe end', 'dfi', 'gas', 'Grt'...etc.)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;some strings are upper case, some are lower case, some are both upper and lower case, some has more than one word. Any suggestion &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;would be appreciated. Thank you.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 19:52:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-variable/m-p/675124#M203360</guid>
      <dc:creator>nirsan</dc:creator>
      <dc:date>2020-08-06T19:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-variable/m-p/675130#M203364</link>
      <description>&lt;P&gt;Please describe exactly what you are attempting to do. This may include an example of what the source data looks like and what the desired output should look like, best as data steps to create data sets so there are no questions about the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you think you need any macro variables for this project?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 20:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-variable/m-p/675130#M203364</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-06T20:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/string-variable/m-p/675131#M203365</link>
      <description>&lt;P&gt;1) All given tree codes seem to be numeric. I assume this is the real situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; in case some tree codes may be alphanumeric just change the type.&lt;/P&gt;
&lt;P&gt;2) The alternative logic is to have the tree codes as a dataset and merge it with your HAVE dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tree_codes;
   infile cards;
   input tree_type;  /* add $ for char type */
cards;
999 
888 
777 
444 
.....
; run;
proc sort data=tree_codes; by tree_type; run;
proc sort data=have; by tree_type; run;

data want;
merge have (in=in1)
          tree_codes(in=in2);
  by tree_type;
      if in1 and in2 then tree_type=1;
run;
proc print data=want(where=(tree_type=1));
var id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Aug 2020 20:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/string-variable/m-p/675131#M203365</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-08-06T20:35:15Z</dc:date>
    </item>
  </channel>
</rss>

