🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-27-2019 07:13 PM
(1827 views)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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;
5 REPLIES 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
select nobs from dictionary.tables
where libname = "XXXXXXX" and memname = "YYYYYY";
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I can work with that. Much thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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