hello team,
I have a proc sql:
proc sql noprint;
select nobs into :TOTOBS separated by " " from dictionary.tables
where libname = "work" and ...
quit;
(To some extend I know what dictionary tables are)
How can we view the dictionary tables and find out what the variables are?
Why does it say separated by " "?
Regards,
blueblue
You view them the same way you view any other SAS data sets (the exact answer depends on what SAS interface you use)
You can view macro variable &TOTOBS via
%put &=TOTOBS;
Dictionary.TABLE is data set SASHELP.VTABLE
Dictionary.columns is data set SASHELP.VCOLUMN
Dictionary.FunkAndWagnalls is data set ... um ... nevermind ...
libname="work" never works because the dictionary tables contain uppercase libnames and data set names (memnames)
separated by " " creates a macro variable named TOTOBS that is not the total or the sum, but the number of observations (variable nobs) in each data set (as a character string) appended to each other and separated by a blank, kind of useless if you ask me.
Hello,
I am grateful to your response:
I can't figure out what you mean by saying:
Dictionary.TABLE is data set SASHELP.VTABLE
Dictionary.columns is data set SASHELP.VCOLUMN
TOTOBS that is not the total or the sum, but the number of observations (variable nobs) in each...
What would be TOTOBS for the first observation in dataset A which has 30 rows?
Regards,
blueblue
Seems pretty obvious to me. The dictionary tables are SAS data sets.
Can you please be much more specific about your question?
Hello PaigeMiller,
Can you please let me know how I can view this below?
Dictionary.TABLE is data set SASHELP.VTABLE
Dictionary.columns is data set SASHELP.VCOLUMN
Can you please let me know how I can view this below?
libname="work" never works because the dictionary tables contain uppercase libnames and data set names (memnames)
Can you please let me know how I can view this below? I worked for hard to see totobs for each observation on the log but I couldn't. What would be the totobs for observation 1?
separated by " " creates a macro variable named TOTOBS that is not the total or the sum, but the number of observations (variable nobs) in each data set (as a character string) appended to each other and separated by a blank, kind of useless if you ask me.
Respectfully,
blueblue
You view them the same way you view any other SAS data sets (the exact answer depends on what SAS interface you use)
You can view macro variable &TOTOBS via
%put &=TOTOBS;
Hi,
%put &=totoobs saved my life.
Author of the code had: %put number of records = &totobs.
when I run the code, I don't see anything except static for %put number of records = &totobs.
he has printto as well. I commented out that part.
What is the rule to see everything on the log? I look into log to find out the code but most of the time, the log doesn't say very much.
Regards,
blueblue
@GN0001 wrote:
Hi,
%put &=totoobs saved my life.
Author of the code had: %put number of records = &totobs.
when I run the code, I don't see anything except static for %put number of records = &totobs.
he has printto as well. I commented out that part.
What is the rule to see everything on the log? I look into log to find out the code but most of the time, the log doesn't say very much.
All of this is unspecific and impossible to answer. Whenever the code isn't working (now and 100% of the time in the future), you need to SHOW US the log that you are seeing, including everything, including the code as it appears in the log, plus any WARNINGs, ERRORs, NOTEs. Do not pick and choose parts of the log to show us, show us ALL of log for this batch of code.
Paste the log as text (not as a screen capture) into the window that appears when you click on the </> icon. DO NOT SKIP THIS STEP.
Hello,
Are there other ways to view values in log?
Most of the time, I can see values are not shown on log, it is code only. Other than loops, I can't see anything else on the log.
Regards,
blueblue
Sorry I forgot to mention that I use SAS enterprise guide.
Regards,
blue blue
Hello @GN0001,
Just to add:
You can also use the DESCRIBE statement of PROC SQL to find out the variable names of one or more dictionary tables:
proc sql;
describe table dictionary.tables, dictionary.columns /* ... */;
quit;
See the documentation Accessing SAS Information By Using DICTIONARY Tables for the list of table names, the corresponding views in SASHELP and more information.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.