BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JanSamohyl
Calcite | Level 5

Hello,

 

I have a user code producing some ODS charts and I would like to extract some meta-information about them back into SAS. What I would like to know is the titles and keys/values (if using BY statement on charting procedure) of relevant charts, because I would like to build a custom navigation around the charts.

 

I tried to set the ODS destination to document for the user code, and then use PROC DOCUMENT, LIST command to query the document after it was created. I was able to extract the document information (including the keys/values) to the LISTING destination, but I don’t know how and if it is possible to get it back as a SAS dataset, so I could match the charts produced. It seems that LIST statement of PROC DOCUMENT produces a table in the output, but I am stumped as to how to get this table back into SAS.

 

Also, this method doesn’t give me the titles for the charts, I am not sure if there is a way to get this information too by querying the document, but it’s a lesser problem.

 

Here’s some code to illustrate what I was trying to do:

 

DATA WORK;
INPUT X Y P Q;
DATALINES;
1 1 0 0
2 4 0 0
3 9 0 1
4 16 0 1
5 25 1 0
6 36 1 0
7 49 1 1
8 64 1 1
;

PROC PRINT DATA=WORK;

ODS LISTING CLOSE;
ODS DOCUMENT NAME=DOC1;

TITLE "A fishy graph";
PROC SGPLOT DATA=WORK;
BY P Q;
SERIES X=X Y=Y;
RUN;

TITLE "A weird graph";
PROC SGPLOT DATA=WORK;
BY P;
SERIES X=X Y=Y;
RUN;

TITLE;
ODS DOCUMENT CLOSE;
ODS LISTING gpath="/some_path" (url=none);

ODS DOCUMENT NAME=DOC2;
PROC DOCUMENT NAME=DOC1;
LIST /DETAILS BYGROUPS LEVELS=ALL;
QUIT;
ODS DOCUMENT CLOSE;

ODS LISTING CLOSE;
ODS OUTPUT Properties#2(persist=proc)=KEYS;
PROC DOCUMENT NAME=DOC2;
LIST /DETAILS LEVELS=ALL;
QUIT;
ODS OUTPUT CLOSE;
ODS LISTING;

PROC PRINT DATA=KEYS;

 

The final PROC PRINT fails because the WORK.KEYS dataset is not there.. I am not sure what exactly should go to the ODS OUTPUT statement to get the output, but I know if I try the other PROC DOCUMENT that the output of first PROC DOCUMENT is two tables, one for each chart. Or maybe there is an easier approach.

 

Thank you in advance for any help.

(Btw, if that’s of any relevance, I am using SAS Base on mainframe.)

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try:

 

PROC DOCUMENT NAME=DOC1;
LIST /DETAILS BYGROUPS LEVELS=ALL;
ods output Properties=prop;
QUIT;

and check dataset prop.

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Try:

 

PROC DOCUMENT NAME=DOC1;
LIST /DETAILS BYGROUPS LEVELS=ALL;
ods output Properties=prop;
QUIT;

and check dataset prop.

PG
JanSamohyl
Calcite | Level 5

Thank you, that's exactly what I needed!

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
  • 2 replies
  • 915 views
  • 0 likes
  • 2 in conversation