<?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 Compress funtion to keep character and numbers only in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compress-funtion-to-keep-character-and-numbers-only/m-p/919631#M362224</link>
    <description>&lt;P&gt;Hi Folks,&lt;BR /&gt;&lt;BR /&gt;My given data set&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data mixed_data;
  length mixed_variable $20.;
  
  input mixed_variable $20.;
  datalines;
aB#5dH0p2Lq8R!xJ7sE9
3kFy@6u1oPwQvZr4Xb2
s9TgY0o2I!qLw5mH8xN7
dC4pL!aB9eR2o7Xn1yH6
6fWvGm9@jP3tNqLr1iH2
bS5lE7dR0oA1!xQ8zC3
Kp2Jr!L6yFw7XsNv9H0e
4uO9rH#tWq1E7sY2cL6
xZ3yF2!iQ8vS0l1Hr7nG
5pA1!mQ9o2W8rHl3vC6
;
run;

proc print data=mixed_data;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;i want keep only character(alphabets) and numbers only and remove other characters and including spaces&lt;BR /&gt;&lt;BR /&gt;I used function Compress(mixed_variable, ,sakkd);&lt;BR /&gt;however s - to remove spaces&lt;BR /&gt;ak - to keep alphabets&amp;nbsp;&lt;BR /&gt;kd - to keep numbers&amp;nbsp;&lt;BR /&gt;are there any other way?&lt;BR /&gt;&lt;BR /&gt;I am not sure of sakkd function my output if fine but i want make sure its does a right job I want other ways and validation as well&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 09 Mar 2024 12:00:37 GMT</pubDate>
    <dc:creator>carl_miles</dc:creator>
    <dc:date>2024-03-09T12:00:37Z</dc:date>
    <item>
      <title>Compress funtion to keep character and numbers only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-funtion-to-keep-character-and-numbers-only/m-p/919631#M362224</link>
      <description>&lt;P&gt;Hi Folks,&lt;BR /&gt;&lt;BR /&gt;My given data set&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data mixed_data;
  length mixed_variable $20.;
  
  input mixed_variable $20.;
  datalines;
aB#5dH0p2Lq8R!xJ7sE9
3kFy@6u1oPwQvZr4Xb2
s9TgY0o2I!qLw5mH8xN7
dC4pL!aB9eR2o7Xn1yH6
6fWvGm9@jP3tNqLr1iH2
bS5lE7dR0oA1!xQ8zC3
Kp2Jr!L6yFw7XsNv9H0e
4uO9rH#tWq1E7sY2cL6
xZ3yF2!iQ8vS0l1Hr7nG
5pA1!mQ9o2W8rHl3vC6
;
run;

proc print data=mixed_data;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;i want keep only character(alphabets) and numbers only and remove other characters and including spaces&lt;BR /&gt;&lt;BR /&gt;I used function Compress(mixed_variable, ,sakkd);&lt;BR /&gt;however s - to remove spaces&lt;BR /&gt;ak - to keep alphabets&amp;nbsp;&lt;BR /&gt;kd - to keep numbers&amp;nbsp;&lt;BR /&gt;are there any other way?&lt;BR /&gt;&lt;BR /&gt;I am not sure of sakkd function my output if fine but i want make sure its does a right job I want other ways and validation as well&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2024 12:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-funtion-to-keep-character-and-numbers-only/m-p/919631#M362224</guid>
      <dc:creator>carl_miles</dc:creator>
      <dc:date>2024-03-09T12:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Compress funtion to keep character and numbers only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-funtion-to-keep-character-and-numbers-only/m-p/919632#M362225</link>
      <description>&lt;P&gt;I would think the final argument to COMPRESS would be 'adk'&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2024 12:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-funtion-to-keep-character-and-numbers-only/m-p/919632#M362225</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-03-09T12:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Compress funtion to keep character and numbers only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-funtion-to-keep-character-and-numbers-only/m-p/919633#M362226</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  New_Var=compress(mixed_variable, '', 'p');
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To remove any punctuation or special characters&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2024 13:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-funtion-to-keep-character-and-numbers-only/m-p/919633#M362226</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2024-03-09T13:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Compress funtion to keep character and numbers only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compress-funtion-to-keep-character-and-numbers-only/m-p/919641#M362229</link>
      <description>&lt;P&gt;If space are important then include some spaces in the test data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mixed_data;
  input mixed_variable $20.;
  datalines;
aB#5dH0p2Lq8R!xJ7sE9
3kFy @6u1oPwQvZr4Xb2
s9TgY0o2I!qLw5mH8xN7
dC4pL!aB9eR2o7Xn1yH6
6fWvGm9@jP3tNqLr1iH2
bS5lE 7dR0oA1!xQ8zC3
Kp2Jr!L6yFw7XsNv9H0e
4uO9rH# tWq1E7sY2cL6
xZ3yF2!iQ8vS0l1Hr7nG
5pA1!m    Hl3 v   C6
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It sounds like you are saying you want to eliminate everything except digits letters and spaces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set mixed_data;
  want = compress(mixed_variable,' ','kad');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will generate:&lt;/P&gt;
&lt;PRE&gt;Obs       mixed_variable              want

  1    aB#5dH0p2Lq8R!xJ7sE9    aB5dH0p2Lq8RxJ7sE9
  2    3kFy @6u1oPwQvZr4Xb2    3kFy 6u1oPwQvZr4Xb2
  3    s9TgY0o2I!qLw5mH8xN7    s9TgY0o2IqLw5mH8xN7
  4    dC4pL!aB9eR2o7Xn1yH6    dC4pLaB9eR2o7Xn1yH6
  5    6fWvGm9@jP3tNqLr1iH2    6fWvGm9jP3tNqLr1iH2
  6    bS5lE 7dR0oA1!xQ8zC3    bS5lE 7dR0oA1xQ8zC3
  7    Kp2Jr!L6yFw7XsNv9H0e    Kp2JrL6yFw7XsNv9H0e
  8    4uO9rH# tWq1E7sY2cL6    4uO9rH tWq1E7sY2cL6
  9    xZ3yF2!iQ8vS0l1Hr7nG    xZ3yF2iQ8vS0l1Hr7nG
 10    5pA1!m    Hl3 v   C6    5pA1m    Hl3 v   C6
&lt;/PRE&gt;
&lt;P&gt;If you also want to eliminate spaces then do not put anything at all for the second argument.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  want = compress(mixed_variable,,'kad');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or put some character you DO want to keep in the second argument.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set mixed_data;
  want = compress(mixed_variable,'A','kad');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Mar 2024 15:30:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compress-funtion-to-keep-character-and-numbers-only/m-p/919641#M362229</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-09T15:30:34Z</dc:date>
    </item>
  </channel>
</rss>

