BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
texasmfp
Lapis Lazuli | Level 10

Is there an easy way to create a dataset with one observation and one variable, where the value is the number of obs in another dataset?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

@Kurt_Bremser wrote an SQL query not a DATA step statement:

proc sql;
create table want as 
select nobs 
from dictionary.tables
where libname = "XXXXXXX" and memname = "YYYYYY";
quit;

 

View solution in original post

5 REPLIES 5
texasmfp
Lapis Lazuli | Level 10
Thanks Kurt, but I got an error

56 data want
57 select nobs from dictionary.tables
ERROR: Libref 'dictionary' exceeds 8 characters.
58 where libname = "COMPANY" and memname = "MATCHES";
- -
22 22
200 200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.

ERROR 200-322: The symbol is not recognized and will be ignored.

59 run;
SASKiwi
PROC Star

@Kurt_Bremser wrote an SQL query not a DATA step statement:

proc sql;
create table want as 
select nobs 
from dictionary.tables
where libname = "XXXXXXX" and memname = "YYYYYY";
quit;

 

texasmfp
Lapis Lazuli | Level 10
I can work with that. Much thanks.
novinosrin
Tourmaline | Level 20

Hi @texasmfp  If you are comfortable using Datastep, you could use SASHELP views that basically executes the SQL query demonstrated by @SASKiwi 

So the query would look something like

 

data want;
set sashelp.vtable;
where libname = "XXXXXXX" and memname = "YYYYYY";
run;
SASHELP.VTABLE is a view of DICTIONARY.TABLES

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!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 985 views
  • 1 like
  • 4 in conversation