BookmarkSubscribeRSS Feed
Joycecp
Calcite | Level 5
Hi!

Is it possible to print variable names and labels at the same time in Proc Print? I have lots and lots of variables to print.

Thank you!
7 REPLIES 7
Joycecp
Calcite | Level 5

Does this solution requires that I name every variable?  Or is the "name" in your example a dictionary lookup keyword?  ie How do I get this to work on all my variables in the dataset (1743 of them).

 

Thank you!

Joyce

ballardw
Super User

"Name" and "Label" are variables in the dictionary.columns table.

Note the the Libname and Memname are all uppercase in the dictionary table. If you use Libname='Work' it fails as the libname is "WORK" in the table.

Cynthia_sas
SAS Super FREQ
Hi:
A PROC PRINT on 1743 variables is going to be VERY, VERY wide output. What is your destination of interest. This is going to be too wide for the LISTING window and PDF and RTF outputs will both "wrap" if you are going to use ODS. It is likely that ODS HTML is going to be the only destination to handle this many variables on a report.

(My .02)
cynthia
RahulG
Barite | Level 11

It is not necessary that all variables in dataset should have label. This solution would print label if available.

 

In the below table, provide libname and table to the macro variables and rest of the code should work itself.

 

%let _libname=;
%let _table=;

proc sql noprint;
select catt( name,'=',quote( catt(label,' (',name,')') ) )
into : embed_names_into_labels separated by ' '
from dictionary.columns
where libname="&_libname" and memname="&_table" and not missing(label);
quit;

 

But above reply has a point that saying why do you need such a wide report.

data temp / view = temp;
set &_libname..&_table;
label &embed_names_into_labels;
run;

proc print data=temp label; run;

jeanderson
Fluorite | Level 6
Hi - does this solution still exist? The link doesn't appear to go anywhere, and I was hoping to use it as a resource.
Joycecp
Calcite | Level 5
Yes. That would be a hard output to use! I am printing groups of variables. Similar to survey the data is gathered from into an excel spreadsheet; not all at one time! It's formatted and grouped as the survey. Thank you!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 5717 views
  • 0 likes
  • 5 in conversation