Solved

How to output SAS dataset with variables without ASCII special characters or numbers?

Posted on 2013-05-21
5
688 Views
Last Modified: 2013-05-26
I am trying to output SAS listing of variable "name" without ASCII special characters or numbers?

Below code is where variable "name" contains special characters and numbers. I just also would like to output datasets "data9" and "data10" from dataset "combined" without special characters or numbers.  

proc sql;
    create  table data5 as
    select unique
          name, Var4,
          Var5
    from combined
   where (anyPunct(name) > 0);
 
    create  table data6 as
    select unique
          name, Var4,
          Var5
    from combined
where (anyPunct(name) > 0);
quit;

proc sql;
    create  table data7 as
    select unique
          name, Var4,
          Var5
    from combined
   where (anyDigit(name) > 0);
 
    create  table data8 as
    select unique
          name, Var4,
          Var5
    from combined
where (anyDigit(name) > 0);
quit;

Open in new window

0
Comment
Question by:labradorchik
  • 4
5 Comments
 

Author Comment

by:labradorchik
ID: 39184265
I already tried below code but I had many errors and datasets "data9" and "data10" were not created.  

proc sql;
    create  table data9 as
    select unique
          name, Var4,
          Var5
    from combined
   where ((anyPunct(name) = 0) and (anyDigit(name) = 0));
 
    create  table data10 as
    select unique
          name, Var4,
          Var5
    from combined
where ((anyPunct(name) = 0) and (anyDigit(name) = 0));
quit;

Open in new window

0
 
LVL 11

Assisted Solution

by:theartfuldazzler
theartfuldazzler earned 500 total points
ID: 39185200
Hi

Try using the compress function :

Name2 = compress(name,, "ck") ;

If I remember correctly, the "ck" will Keep Characters only and drop all numbers and special characters.
0
 

Author Comment

by:labradorchik
ID: 39185666
Below code works and outputs variable "name" without any special characters or numbers but I also would like to create another filter:

if Var5  > 5  & < 20 then output to data9 and data10
How may I incorporate this to my already existing "where" statements

proc sql;
    create  table data9 as
    select unique
          name, Var4,
          Var5
    from combined
   where (anyPunct(name) = 0) & (anyDigit(name) = 0);
 
    create  table data10 as
    select unique
          name, Var4,
          Var5
    from combined
where (anyPunct(name) = 0) & (anyDigit(name) = 0);
quit;

Open in new window


I tried below code but it still does not recognize Var5  > 5  & < 20, although, surprisingly no errors. Any comments or suggestions?

proc sql;
    create  table data9 as
    select unique
          name, Var4,
          Var5
    from combined
   where ((anyPunct(name) = 0) & (anyDigit(name) = 0)) & 
   where ((Var5 > 5 | Var5 < 20));
 
    create  table data10 as
    select unique
          name, Var4,
          Var5
    from combined
where (anyPunct(name) = 0) & (anyDigit(name) = 0) &
where ((Var5 > 5 | Var5 < 20));
quit;

Open in new window

0
 

Accepted Solution

by:
labradorchik earned 0 total points
ID: 39185910
theartfuldazzler, thank you very much for your comments!

Your example worked partially but below code worked perfectly:

where (anyPunct(name) = 0) and (anyDigit(name) = 0) and Var5 > 5 and Var5 < 20;

Open in new window

0
 

Author Closing Comment

by:labradorchik
ID: 39197455
The best possible answer was found while testing the code.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now