New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
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

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 1828 views
  • 1 like
  • 4 in conversation