Help using Base SAS procedures

Seams simple enough, count(distinct( a:)) with wildcards

Reply
Contributor
Posts: 20

Seams simple enough, count(distinct( a:)) with wildcards

All i'd like to do is to get a distinct count of all my vars that say start with a.
like in the data step i could use something like Keep= a: ; and it would keep all me vars that started with a.

Proc sql doesn't like the a: (like the a*) dos syntax in my SQL

any ideas to create something like this?

thanks
PROC Star
Posts: 7,363

Re: Seams simple enough, count(distinct( a:)) with wildcards

[pre]
proc sql;
select distinct count(*)
from dictionary.columns
where libname="SASHELP" and memname="CLASS" and
upcase(name) like "A%"
;
quit;
[/pre]
Contributor
Posts: 20

Re: Seams simple enough, count(distinct( a:)) with wildcards

ok, it looks as thought that query is saying that there is one col/var in that Claas table that has var that starts with a A.

what i'm tring to get is a count(distinct()) of all the values in that vars that are A%

thanks
PROC Star
Posts: 7,363

Re: Seams simple enough, count(distinct( a:)) with wildcards

Not sure I understand what you are looking for then. Possibly something like?:
[pre]
proc sql;
select distinct count(*)
from sashelp.class
where upcase(name) like "J%"
;
quit;
[/pre]
Super Contributor
Posts: 578

Re: Seams simple enough, count(distinct( a:)) with wildcards

proc sql;
select count(distinct var)
from work.table where var like 'A%';
quit;
Respected Advisor
Posts: 3,777

Re: Seams simple enough, count(distinct( a:)) with wildcards

[pre]
data class;
retain ab ac ae ag 8;
set sashelp.class;
run;
proc freq data=class nlevels;
ods output nlevels=nlevels;
ods select nlevels;
tables a:;
run;
[/pre]
Ask a Question
Discussion stats
  • 5 replies
  • 162 views
  • 0 likes
  • 4 in conversation