<?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: Capturing data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585841#M167165</link>
    <description>&lt;P&gt;I am pasting sample data for my data set for you play with;&lt;/P&gt;&lt;PRE&gt;input AEKEY:$32. patient_id:$32. link_method:$18. procodet:$3. postcode_flag:$5. sex:$1. ethnos:$2. activage:$32. ARRIVALAGE:$32. pgpprac:$4. sitetret:$5. aearrivalmode:32. aeattenddisp:32. aerefsource:32. aedepttype:32. aearrivaldate:32. aearrivaltime:32.
 diag_scheme:32. diag_01:$6. diag_02:$6. diag_03:$6. diag_04:$6. diag_05:$6. diag_06:$6. diag_07:$6. diag_08:$6. diag_09:$6. diag_10:$6. diag_11:$6. diag_12:$6. invest_01:$4. invest_02:$4. invest_03:$4. invest_04:$4. invest_05:$4. invest_06:$4. invest_07:$
4. invest_08:$4. invest_09:$4. invest_10:$4. invest_11:$4. invest_12:$4. treat_01:$4. treat_02:$4. treat_03:$4. treat_04:$4. treat_05:$4. treat_06:$4. treat_07:$4. treat_08:$4. treat_09:$4. treat_10:$4. treat_11:$4. treat_12:$4. imd15decile_overall:32.;
datalines;
e81e201e78d19d8c3f5122ce7d96c25a 97e023526b0dc2b5e9e08eed37775ab8 NHSNO RXF VALID 1 A 002 73 da48   2 3 1 1 19518 1014 1                         24 24                     34 41                     3
5221b6afed59cee127663fe106688fd0 b76acf7d6e16213737184da41a1794a1 NHSNO RXF VALID 2 J 006 82 37d3   2 3 1 1 19537 1359 1                         01 24                     221 222                     3
c5f9d619392b7317bff4355d7e0c3829 8e19bf9b06f32ea3538b417a69254e3f NHSNO RCB VALID 1 A   16 b6a4 RCB55 2 3 1 1 19165 1602 1                         24                       221 011                     3
42bdbdc79100370c0f7b92e8219c950f 2a44ce4db8a93eb5a111d0900a818351 NHSNO RWY VALID 2 A 016 16 6868 RWY01 2 3 1 1 19104 231 1 05 15L                       01 01                     511                       9
b43c9c6090a4a0eb69b5bd88f8b76e8f 1e46f877744f9cceec87405da4716053 NHSNO RXF VALID 2 A 015 21 b9e9   2 1 1 1 19526 1423 1                         24                       21 511                     4
dd8c32086cfd590049fdeb9817083967 f21138c84b7ea596bb1aeb4a7cbb1e32 NHSNO RWA VALID 1 A 016 16 f6b0 RWA00 2 2 1 1 19051 1123 1 03 25L                       03 24                     291 43 21 12                 3
c810915d6201106c5e9caec870183a21 23f76559afb9135cb92fbcf9072d9957 FULL ID NHSNO LINK RJL VALID 1 A 016 16 V819 RJL32 2 3 1 1 19013 1601 1                         24                       222 21 236 042                 8
4c8808798cb8278f03540122edb7f1b1 1152df925fcc5d927f5e811485338fc0 NHSNO RP5 VALID 2 A 016 16 8e29 RP5DR 2 2 8 1 19094 2115 1 38                       24                       99                       5
4ee99a96e5cdee139f6c7b4a3ec31734 1152df925fcc5d927f5e811485338fc0 NHSNO RP5 VALID 2 A 016 16 8e29 RP5DR 2 5 1 1 19221 2029 1                         01                       222 51                     5
ab1c30f4ae71acebfc5dc9cff812ae53 3ab4b9ec7420ffa8988cfa496116359c NHSNO RCD VALID 2 A 016 16 eade RCD00 9 3 8 1 19090 1933 1                         01                       222                       5
002c5a7a483c7f9a281393e9d5886edd 36c1b661c6472d7c520013558fab9993 NHSNO RXF VALID 1 A 012 41 e7c4   2 12 1 4 19512 952 1 38                       24 24                     27                       2
dcc81124ce35647223c9d78c59bfa4c9 0bb5d959bd1e72c06a523e9179f2325a NHSNO RXF VALID 2 A 007 20 51c5   2 2 0 1 19521 1126 1                         10 24                     21 222                     2
7fe0f97fad130b4cb0f2582fad3a3fd2 64679614526ef9ac7bf460b5b09495ca NHSNO RXF VALID 2 A 008 88 8d1c   1 1 3 1 19536 1755 1                         24 24                     21 222                     10
9c346f3bf96e86c5c11e4c97c8db930d 6cc798e3ad901302d5df814f3fe7334a NHSNO RXF VALID 1 R 002 73 1e3b   1 1 0 1 19523 1238 1                         01                       21 222                     3
d1787cf846fb617e63153dbc7c901e87 12b080b9cc4ba31655ebfdd5c0ee3c27 NHSNO RXF VALID 2 J 011 67 2a39   2 4 0 1 19513 1449 1                         24                       21 222                     8
4f0e6017b9c6da5650d3972a61681599 12b080b9cc4ba31655ebfdd5c0ee3c27 NHSNO RXF VALID 2 L 013 67 2a39   2 3 7 1 19516 1133 1                         24 24                     222                       8
de5e1b9898373a106a4a16ad01cb25c3 50d356d07b3e92e1258e0b35e0cfcc09 NHSNO RP5 VALID 2 A 016 16 50a3 RP5DR 1 2 1 1 19188 1352 1                         01 02                     25 12                     2
3f4118a4e4c224a7478e4b33bb3e6105 50d356d07b3e92e1258e0b35e0cfcc09 NHSNO RP5 VALID 2 A 016 16 50a3 RP5DR 1 2 8 1 19220 1110 1                         02                       99                       2
cdea90793c93c0f14a37e72146351a22 52712651674edb68a015eedfeaa65f48 NHSNO RXF VALID 2 A 004 29 332b   2 3 1 1 19539 710 1                         24 24                     21 222                     9
96a372e7c7f98c481da3fb70a6f22ce1 78240b57dcf604ff84263a80e7e15a2b NHSNO RXF VALID 2 A 009 27 5a1d   2 6 1 1 19533 1306 1                         03 03                     222                       8
;;;;&lt;/PRE&gt;</description>
    <pubDate>Tue, 03 Sep 2019 14:32:53 GMT</pubDate>
    <dc:creator>sks521</dc:creator>
    <dc:date>2019-09-03T14:32:53Z</dc:date>
    <item>
      <title>Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582146#M165521</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got some variables on say for example diagnosis which can be coded as 45, 451, 459, 458. So all these observations have 45 in common. I want to capture all observations which has values starting with 45 without writing an entire list of codes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I do that please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 15:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582146#M165521</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2019-08-19T15:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582150#M165524</link>
      <description>Is it numeric or character variables?&lt;BR /&gt;&lt;BR /&gt;If character use a colon operator with the equal sign to check the first two characters only. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if diag_code =: '45';&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Aug 2019 16:02:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582150#M165524</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-19T16:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582162#M165527</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
x=45;  output;
x=451; output;
x=459; output;
x=458; output;
x=75;  output;
x=951; output;
x=729; output;
x=458; output;
run;

data want;
	set have;
	if substr(left(x),1,2)='45';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Aug 2019 16:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582162#M165527</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-08-19T16:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582191#M165548</link>
      <description>&lt;P&gt;If you have multiple variables you&amp;nbsp; may want to consider an array and testing each value, such as with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s approach and if none of the variables match, then delete the record. Ease may depend on number of variables involved:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way with some very limited character data:&lt;/P&gt;
&lt;PRE&gt;data example;
   informat d1-d3 $5.;
   input d1 d2 d3;
   array d d1-d3;
   flag=0;
   do i= 1 to dim(d);
      flag= (d[i] =: '45');
      if flag then leave;
   end;
   if flag=0 then delete;
   drop i flag;

datalines;
123 456 789
123 234 642
450 124 444
123 124 459
;
run;&lt;/PRE&gt;
&lt;P&gt;A question that my need consideration:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do you have values such as '45123', longer than the 3 characters that you showed that show NOT be considered as in the wanted&amp;nbsp; values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 17:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582191#M165548</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-19T17:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582306#M165603</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;Frankly, I have an aversion to implicit data type conversions, so I'd rather do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                    
  do x = 45, 451, 459, 458, 75, 951, 729, 458 ;
    output ;                                   
  end ;                                        
run ;                                          
                                               
data want ;                                    
  set have ;                                   
  if put (x, D.-L) =: "45" ;                   
run ;                                          
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or, without any type conversions, explicit or implicit:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;                                       
  set have ;                                      
  if int (x / 10 ** (int (log10 (x)) - 1)) = 45 ;
run ;                                             
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That having been said, codes of this nature are always of the character type (usually $5), as they may contain alphas. Hence, it would be apter to model the sample data set accordingly, which in turn makes the subsetting process much simpler:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                      
  do _n_ = 45, 451, 459, 458, 75, 951, 729, 458 ;
    x = put (_n_, 5.-L) ;                        
    output ;                                     
  end ;                                          
run ;                                            
                                                 
data want ;                                      
  set have (where = (x =: "45")) ;                                 
run ;                                            
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 04:11:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582306#M165603</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-20T04:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582350#M165625</link>
      <description>&lt;P&gt;Yes, I am looking for&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'251', 'J441','J450', 'J45', 'J451','J458', 'J459', 'J46', 'J46X', 'R062', 'J44.1', 'J441-', 'J44x'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in a number of variables named as 'diag_01 to diag_06'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I write that in syntax please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 09:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582350#M165625</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2019-08-20T09:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582355#M165629</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277970"&gt;@sks521&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Essentially the same way&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;has already suggested:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop = _:) ;
  set have ;
  array d diag: ;
  do over d ;
    if d in ('251', 'J441','J450', 'J45', 'J451','J458', 'J459', 'J46', 'J46X', 'R062', 'J44.1', 'J441-', 'J44x') then do ;
      _FOUND = 1 ;
      leave ;&lt;BR /&gt;    end ;
  end ;
  if _FOUND ; * if you want only the records where you have a match ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 09:20:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/582355#M165629</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-20T09:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/583475#M166100</link>
      <description>&lt;P&gt;But this code does involve listing all the values and in this specific case I don't know the exact values, as some clinicians would have coded a diagnosis as '45', another as '45X' and another as '45.0', so I don't want to worry about what comes after '45'. I only want to tell SAS to pick any value starting with 45 regardless of 'X', '.', '-' etc. etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I write that please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2019 13:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/583475#M166100</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2019-08-23T13:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/583498#M166108</link>
      <description>&lt;P&gt;Also wanted to ask if SAS would take '05 17R' as '0517R' or do I have to specify space between 05 and 17R.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2019 14:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/583498#M166108</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2019-08-23T14:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/583586#M166134</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277970"&gt;@sks521&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Sorry, but I'm confused now.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You said that you wanted to pick the values that start with 45.&lt;/P&gt;
&lt;P&gt;Yet you also gave a sample of codes, &lt;EM&gt;none of which starts with 45&lt;/EM&gt; but may &lt;EM&gt;start with a letter (for instance, J) followed by 45&lt;/EM&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;'251', 'J441','J450', 'J45', 'J451','J458', 'J459', 'J46', 'J46X', 'R062', 'J44.1', 'J441-', 'J44x'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Which makes me conjecture that you want make your SAS code react to the codes whose &lt;EM&gt;first two &lt;FONT color="#0000FF"&gt;digits&lt;/FONT&gt; are 45&lt;/EM&gt;, regardless of whether they are preceded by a non-digit or not. In other words, if my conjecture held water, you'd like SAS to react to the following selection from the above list:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;'J450', 'J45', 'J451','J458', 'J459'&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is that correct? If so, your condition should begin with the &lt;EM&gt;first digit&lt;/EM&gt; in any code, rather than at character #1. In other words, given the data sample HAVE below, you'd want to select records #1, 2, and 5:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                        
  input (diag1-diag3) (:$5.) ;                     
  cards ;                                          
251  J441  450XY                                   
J45  J451  J458                                    
J469 J46   J46X                                    
R062 J44.1 J441                                    
J469 45XX  J46X                                    
run ;                                              
                                                   
data want (drop = _select) ;                      
  set have ;                                       
  array dd diag: ;                                 
  do over dd ;                                     
    if substr (dd, anydigit (dd)) =: "45" then do ;
      _select = 1 ;                                
      leave ;                                      
    end ;                                          
  end ;                                            
  if _select ;                                     
run ;                                              
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead of the expression:&lt;/P&gt;
&lt;PRE&gt;substr (dd, anydigit (dd))&lt;/PRE&gt;
&lt;P&gt;you can also use:&lt;/P&gt;
&lt;PRE&gt;compress (dd, , "kd")
&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2019 19:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/583586#M166134</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-23T19:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585559#M167002</link>
      <description>&lt;P&gt;Hi Paul,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry about the confusion. I was just giving an example as got multiple diagnoses that I would want to pick up using this code. Here is the description;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gastroenteritis is entered as&amp;nbsp;&lt;/P&gt;&lt;P&gt;262, 263, 262248, K52, P783, A00, A02, A03, A04, A05, A06, A07, A08, A09, A084, A080, A083, A059, A090, A099&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and asthma is coded as;&lt;/P&gt;&lt;P&gt;251, 251228, J441, J450, J45, J451, J458, J459, J46, J46X, R062&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I would, say for example, want to pick any codes that have 26, A0 for gastroenteritis and J44, J45, 251 for asthma.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I write it please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 09:30:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585559#M167002</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2019-09-02T09:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585567#M167010</link>
      <description>&lt;P&gt;And also, how do we write this array if we wanted to drop observations with diagnoses codes (given in variables diag_01 to diag_09) including values like J21, J0, J38, J37 regardless of values/digits/characters before and after them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 10:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585567#M167010</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2019-09-02T10:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585658#M167069</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277970"&gt;@sks521&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Just apply a separate condition with the colon modifier for each spec condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                             
  input (diag1-diag3) (:$6.) ;                          
  cards ;                                               
251  J441   450XY                                       
J45  J451   J458                                        
J469 J46    J46X                                        
R062 J44.1  J441                                        
J469 45XX   J46X                                        
262  263    262248                                      
K52  P783   A00                                         
A02  A03    A04                                         
A05  A06    A07                                         
A08  A09    A084                                        
A080 A083   A059                                        
251  251228 J441                                        
J450 J45    J451                                        
J458 J459   J46                                         
J46X R062   P783                                        
run ;                                                   
                                                        
data want ;                                             
  set have ;                                            
  array dd diag: ;                                      
  do over dd ;                                          
    if dd in: ("26"  "A0"       ) then flag_gastro = 1 ;
    if dd in: ("J44" "J45" "251") then flag_asthma = 1 ;
  end ;                                                 
* if flag_gastro or flag_asthma ;                       
* drop flag_: ;                                         
run ;                                                   
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want only the output observations with either gastro or asthma codes found, uncomment the two penultimate lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 20:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585658#M167069</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-02T20:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585660#M167070</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277970"&gt;@sks521&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;You'd need the corresponding number of FIND expressions conjugated by ORs. But in such a case, it's simpler, easier, and less verbose to use the PRXMATCH function - you can judge by comparing the line where it's used with the commented out line with the FINDs below (both lines yield the same result):&lt;/P&gt;
&lt;PRE&gt;data have ;                                                                                 
  input (diag1-diag3) (:$6.) ;                                                              
  cards ;                                                                                   
251  J441   450XY                                                                           
1&lt;FONT color="#800000"&gt;&lt;STRONG&gt;J21&lt;/STRONG&gt;&lt;/FONT&gt;  J451  J458                                                                            
J469 J46    J46X                                                                            
R062 &lt;FONT color="#800000"&gt;&lt;STRONG&gt;J0&lt;/STRONG&gt;&lt;/FONT&gt;XX   J441                                                                            
J455 45XX   J46X                                                                            
262  263    62&lt;FONT color="#800000"&gt;&lt;STRONG&gt;J38&lt;/STRONG&gt;&lt;/FONT&gt;                                                                           
K52  P783   A00                                                                             
A02  A0&lt;FONT color="#800000"&gt;&lt;STRONG&gt;J37&lt;/STRONG&gt;&lt;/FONT&gt;3 A04                                                                             
run ;                                                                                       
                                                                                            
data want (drop = _:) ;                                                                     
  set have ;                                                                                
  array dd diag: ;                                                                          
  do over dd ;                                                                              
    if prxmatch ("m/J21|J0|J38|J37/oi", dd) then do ;                                       
  * if find (dd, "J21") or find (dd, "J0") or find (dd, "J38") or find (dd, "J37") then do ;
      _exclude = 1 ;                                                                        
      leave ;                                                                               
    end ;                                                                                   
  end ;                                                                                     
  if not _exclude ;                                                                         
run ;                                                                                       
&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 20:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585660#M167070</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-02T20:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585669#M167074</link>
      <description>&lt;P&gt;Or :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE ;                                                                                 
  input (DIAG1-DIAG3) (:$6.) ;                                                              
  cards ;                                                                                   
251  J441   450XY                                                                           
1J21  J451  J458                                                                            
J469 J46    J46X                                                                            
R062 J0XX   J441                                                                            
J455 45XX   J46X                                                                            
262  263    62J38                                                                           
K52  P783   A00                                                                             
A02  A0J373 A04                                                                             
run;                                                                                       
                                                                                            
data WANT;                                                                     
  set HAVE;                                                                                
  FLAG_GASTRO=prxmatch ("m/\b26|\bA0/oi"        , catx(' ',of DIAG:)) &amp;gt; 0;                                       
  FLAG_ASTHMA=prxmatch ("m/\bJ44|\bJ45|\b251/oi", catx(' ',of DIAG:)) &amp;gt; 0;                                       
run;           &lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;DIAG1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;DIAG2&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;DIAG3&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;FLAG_GASTRO&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;FLAG_ASTHMA&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;251&lt;/TD&gt;
&lt;TD class="l data"&gt;J441&lt;/TD&gt;
&lt;TD class="l data"&gt;450XY&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;1J21&lt;/TD&gt;
&lt;TD class="l data"&gt;J451&lt;/TD&gt;
&lt;TD class="l data"&gt;J458&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;J469&lt;/TD&gt;
&lt;TD class="l data"&gt;J46&lt;/TD&gt;
&lt;TD class="l data"&gt;J46X&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;R062&lt;/TD&gt;
&lt;TD class="l data"&gt;J0XX&lt;/TD&gt;
&lt;TD class="l data"&gt;J441&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;J455&lt;/TD&gt;
&lt;TD class="l data"&gt;45XX&lt;/TD&gt;
&lt;TD class="l data"&gt;J46X&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;262&lt;/TD&gt;
&lt;TD class="l data"&gt;263&lt;/TD&gt;
&lt;TD class="l data"&gt;62J38&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;K52&lt;/TD&gt;
&lt;TD class="l data"&gt;P783&lt;/TD&gt;
&lt;TD class="l data"&gt;A00&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;A02&lt;/TD&gt;
&lt;TD class="l data"&gt;A0J373&lt;/TD&gt;
&lt;TD class="l data"&gt;A04&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;\b&amp;nbsp; means the word begins there&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 01:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585669#M167074</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-03T01:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585671#M167075</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very clever!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Committed to my storage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2019 22:19:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585671#M167075</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-02T22:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585723#M167106</link>
      <description>&lt;P&gt;I have run this array but getting an error message as follows; (these are all character variables listed as treat_01 to treat_12)&lt;/P&gt;&lt;PRE&gt;285  data CONTROL1 (drop = _:) ;
286    set VISITS ;
287    array dd TREAT: ;
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
ERROR: All variables in array list must be the same type, i.e., all numeric or character.
288    do over dd ;
289      if prxmatch ("m/J21|J0|J38|J37/oi", dd) then do ;
290    * if find (dd, "J21") or find (dd, "J0") or find (dd, "J38") or find (dd, "J37") then do ;
291        _exclude = 1 ;
292        leave ;
293      end ;
294    end ;
295    if not _exclude ;
296  run ;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      289:41
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.CONTROL1 may be incomplete.  When this step was stopped there were 0
         observations and 30 variables.
WARNING: Data set WORK.CONTROL1 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Sep 2019 08:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585723#M167106</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2019-09-03T08:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585746#M167117</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/277970"&gt;@sks521&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;The SAS log tells you plainly that different TREAT* variables have both character and numeric data types. From the standpoint of process organization and the nature of the task, this is called "dirty data": They should be all character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;EM&gt;proper&lt;/EM&gt; solution is to convert all the numeric TREAT variables to character; then the code will run error-free.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A palliative solution is to use the CATX trick offered by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;, as unlike an array, the collective colon (:) modifier reference doesn't suggest the same data type across all TREAT: variables&amp;nbsp;in the context of using it with the CATX function, since the latter converts numeric variables to the character type automatically:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT ;                                                                     
  set HAVE ;                                                                                
  if prxmatch ("m/\b26|\bA0/oi", catx (' ', of TREAT:)) = 0
  and                                       
  prxmatch ("m/\bJ44|\bJ45|\b251/oi", catx (' ', of TREAT:)) = 0
  ;                                       
run ;           &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 10:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585746#M167117</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-09-03T10:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585750#M167121</link>
      <description>&lt;P&gt;Thanks but can I check in if this step will get rid of all observations with any diagnoses other than the ones specified (asthma and gastroenteritis) here please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 10:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585750#M167121</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2019-09-03T10:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585833#M167160</link>
      <description>&lt;P&gt;Hi Paul,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are all character variables and I have defined them as character variables while importing data into SAS. How come&amp;nbsp; I am getting errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And also I have tried to use the syntax you suggested but still getting errors, this time using diagnosis variables;&lt;/P&gt;&lt;PRE&gt;*Deleting observations with croup diagnosis;
*USING ARRAY FROM THE SAS SUPPORT COMMUNITY;
data CONTROL1 (drop = _:) ;                                                                     
  set VISITS ;                                                                                
  array dd diag: ;                                                                          
  do over dd ;                                                                              
    if prxmatch ("m/J05/oi", catx (' ', of diag:)) then do ;                                       
  * if find (dd, "J21") or find (dd, "J0") or find (dd, "J38") or find (dd, "J37") then do ;
      _exclude = 1 ;                                                                        
      leave ;                                                                               
    end ;                                                                                   
  end ;                                                                                     
  if not _exclude ;                                                                         
run ;       &lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Sep 2019 14:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Capturing-data/m-p/585833#M167160</guid>
      <dc:creator>sks521</dc:creator>
      <dc:date>2019-09-03T14:20:16Z</dc:date>
    </item>
  </channel>
</rss>

