BookmarkSubscribeRSS Feed
SAS_INFO
Quartz | Level 8

Hi All,

 

I am trying to export all the variable name, their trype(char, num, data), along with their dataset name to a Excel sheet.

 

Tried the following code(thanks to SASKIWI) , but got only the list of variables name and respective dataset thary belong, i need the variable type as well.

 

Please suggest

/* Note that value of libname is UPPERCASE */

proc sql;

create table columns as

select name as variable

,memname as table_name

from dictionary.columns

where libname = 'WORK'

;

quit;

/* SAS 9.4 or later */

ods excel file="C:\e_Contents.xlsx" style=minimal;

proc print data=columns;

run;

ods excel close;

/* earlier versions, using SAS/ACCESS to PC Files */

PROC EXPORT data = columns

OUTFILE = 'e_Contents.xls'

DBMS = EXCEL REPLACE;

SHEET='VARLIST';

RUN;

2 REPLIES 2
SAS_INFO
Quartz | Level 8

thanks Guys,

Got it....

 

the following code works

 

Proc contents data=work._ALL_;

run;

ballardw
Super User

If you use this code you can find out how to request other items from dictionary.columns

proc sql;
   describe table dictionary.columns;
run;

which would lead to

proc sql;
   create table columns as
   select name as variable
   ,memname as table_name,type
   from dictionary.columns
   where libname = 'WORK'
;
quit;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 807 views
  • 0 likes
  • 2 in conversation