BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BrahmanandaRao
Lapis Lazuli | Level 10
	data ds;
	set sahelp.class;
	run;

	
	data ds1;
	set sashelp.class;
	run;


 proc sql;
	select Name,count(Name) 
	from dictionary.columns
	where libname='WORK'
	group by name
	having count(Name)>2;
	quit;

	
	

no output  

i want output comman variables count in work libraray

1 ACCEPTED SOLUTION

Accepted Solutions
SASJedi
SAS Super FREQ

Your first DATA step is not executing because you misspelled "sashelp" as "sahelp". First, correct that.

Next, your SQL query asks for rows where the count is >2. Because you only have 2 data sets created, no rows meet the criteria, so no output. 

With the code corrected:

data ds;
	set sashelp.class;
run;

data ds1;
	set sashelp.class;
run;

 proc sql;
select Name,count(Name) 
	from dictionary.columns
	where libname='WORK'
	group by name
	having count(Name)>=2;
quit;

You get results:

Column Name  
Age 2
Height 2
Name 2
Sex 2
Weight 2
Check out my Jedi SAS Tricks for SAS Users

View solution in original post

2 REPLIES 2
maguiremq
SAS Super FREQ

I'm not quite sure I understand why you're counting variables. Could you explain? The code below will return common variables between data sets, but that doesn't seem to be what you want according to your post.

 

Edit: I meant to use the intersect operator.

 

proc sql;
	select
				name
	from
				dictionary.columns
	where
				libname = "WORK"	and
				memname = "DS"
	intersect
	select
				name
	from
				dictionary.columns
	where	
				libname = "WORK" 	and
				memname = "DS1";
quit;

 

SASJedi
SAS Super FREQ

Your first DATA step is not executing because you misspelled "sashelp" as "sahelp". First, correct that.

Next, your SQL query asks for rows where the count is >2. Because you only have 2 data sets created, no rows meet the criteria, so no output. 

With the code corrected:

data ds;
	set sashelp.class;
run;

data ds1;
	set sashelp.class;
run;

 proc sql;
select Name,count(Name) 
	from dictionary.columns
	where libname='WORK'
	group by name
	having count(Name)>=2;
quit;

You get results:

Column Name  
Age 2
Height 2
Name 2
Sex 2
Weight 2
Check out my Jedi SAS Tricks for SAS Users

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 414 views
  • 1 like
  • 3 in conversation