DATA Step, Macro, Functions and more

How to retrieve these information of a dataset

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 76
Accepted Solution

How to retrieve these information of a dataset

[ Edited ]

Hi everyone, I'm using SAS 9.3.

Does anyone have suggestions to retrieve "label", "size in byte", "observations (total rows)" and "created date" of a dataset, and also print it out?


Accepted Solutions
Solution
‎04-30-2017 02:37 AM
Super User
Posts: 19,875

Re: How to retrieve these information of a dataset

Posted in reply to JohnChen_TW

 

Did you look at SAS.VTABLE? The field called memlabel holds the label. This works for my example below

 

data test (label='mydata');
set sashelp.class;
run;


PROC SQL;
CREATE TABLE info AS 
SELECT * 
FROM SASHELP.VTABLE
WHERE libname='WORK' and MEMNAME = 'TEST';
QUIT;

 

 

 

View solution in original post


All Replies
Frequent Contributor
Posts: 93

Re: How to retrieve these information of a dataset

Posted in reply to JohnChen_TW
PROC SQL;
CREATE TABLE COLNAMES AS SELECT * 
FROM DICTIONARY.COLUMNS 
LEFT JOIN DICTIONARY.TABLES TABLES ON TABLES.MEMNAME = COLUMNS.MEMNAME
WHERE TABLES.MEMNAME = 'FLARM';
QUIT;

To get the total number of answers, you may want to create a looping macro to select count(case when col1 is not null then 1 else 0 end) for each of the variables, depending on their data type, and update your columns table.

 

Patrick

Super User
Posts: 19,875

Re: How to retrieve these information of a dataset

Posted in reply to JohnChen_TW

To add to @thomp7050 correct answer, use SASHELP.Vtable for information on a dataset and SASHELP.vcolumn for information on variables within a specific dataset. These are also known as dictionary.table and dictionary.column but you can't navigate to those, so I use the SASHELP convention to denote this. 

Frequent Contributor
Posts: 93

Re: How to retrieve these information of a dataset

Thank you, Reeza.  You have added to my knowledge today.

Frequent Contributor
Posts: 76

Re: How to retrieve these information of a dataset

Thanks for your suggestion.

 

But I'd like to print the label on dataset (shown as below), not column label.

未命名.png

 

How to create another dataset to save "label on dataset as above", file size, created date, and observations?

 

JC

Solution
‎04-30-2017 02:37 AM
Super User
Posts: 19,875

Re: How to retrieve these information of a dataset

Posted in reply to JohnChen_TW

 

Did you look at SAS.VTABLE? The field called memlabel holds the label. This works for my example below

 

data test (label='mydata');
set sashelp.class;
run;


PROC SQL;
CREATE TABLE info AS 
SELECT * 
FROM SASHELP.VTABLE
WHERE libname='WORK' and MEMNAME = 'TEST';
QUIT;

 

 

 

Frequent Contributor
Posts: 76

Re: How to retrieve these information of a dataset

Many thanks for your resolution.
I am not good at proc SQL, actually.

JC
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 157 views
  • 1 like
  • 3 in conversation