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
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 |
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;
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 |
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: