BookmarkSubscribeRSS Feed
JaneS
Calcite | Level 5

I created a couple of data sets in sas that export to excel. I need to create a description tab that describe my data sets. I was tying to find out a code sample for SAS, where I could put some text in that code and it would create a tab in XL file with that text in it. 

 

Thank you!

6 REPLIES 6
Reeza
Super User

Pipe the results from SASHELP.VTABLE or VCOLUMNS to an excel file within and ODS EXCEL?

 

ods excel file = "/folders/myfolders/demo.xlsx" style=meadow;

proc print data=sashelp.vcolumn;
where libname = 'SASHELP' and memname = 'CLASS';
var libname memname name type length format;
run;

ods excel options(sheet_interval="NOW");

proc print data=sashelp.class;
run;

ods excel close;

Conceptually, I think you're looking for something like that. You can also use PROC ODSTEXT to pipe text directly to the report.

 


@JaneS wrote:

I created a couple of data sets in sas that export to excel. I need to create a description tab that describe my data sets. I was tying to find out a code sample for SAS, where I could put some text in that code and it would create a tab in XL file with that text in it. 

 

Thank you!


 

ballardw
Super User

Possibly just Proc Contents for the data sets of interest?

Reeza
Super User
Probably a better example! But I suspect they may also want the PROC ODSTEXT part based on this statement "where I could put some text in that code and it would create a tab in XL file with that text in it."

But using a data set label or extra metadata on data sets could also be a good option.
JaneS
Calcite | Level 5

Thank you so much for everyone's reply! I am a little confused about this code, as where would I paste  text. Just as an example, if I have this text: 

Filter 1: Step-by-step instructions
  1. Locate your water filter cover in the upper right-hand corner inside your refrigerator or in the base grille.
  2. Lift the filter door up.
  3. Pull the filter out and discard it.
  4. Open your new filter and remove the protective coverings from the O-rings. Make sure the O-rings are still in place after the cover has been removed.
  5. When inserting the new filter into the slot, make sure the arrow is pointing upward. Do not force the water filter. If it does not slide in easily, rotate it until the notches are properly aligned with the grooves.
  6. Push the filter door closed so it snaps into place.
  7. Once your filter is replaced, run four gallons of water through the line to properly flush the new filter.
where/how should I paste it in SAS code so that it would populate in the XL for me? 
 
Thank you!
Reeza
Super User
Did you look into PROC ODSTEXT?

Or just save it to a data set and use PROC PRINT or PROC REPORT?

data have;
text = 'Filter 1: Step by step instructions'; indent = 0;output;
text = '1. Locate your water filter....'; indent = 1; output;
run;

proc print data=have;
run;



GraphGuy
Meteorite | Level 14

Assuming your datasets have labels, you could do something like this using sashelp.vtable (which is a table that exists behind-the-scenes, storing summary info about the datasets):

 

proc sql noprint;
create table summary as
select unique memname, memlabel
from sashelp.vtable
where libname='MAPSGFK'
and memname in ('FRANCE' 'GERMANY' 'EGYPT');
quit; run;

 

title "Datasets in this spreadsheet";
proc print data=summary label noobs;
run;

 

vtable.png

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 831 views
  • 2 likes
  • 4 in conversation