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

Hello Experts,

 

I'm wondering how to create a file by name. For exemple, in this example we create the file for each name (with obj.open_dir(name: name, label: "", by: 1); 

I would like to add the name on the pdf file like Carte_(name of student).pdf 

 

Do you know please how to variate the name of pdf file by observation ?

title; ods listing close; ods html close; options nodate nonumber; ods escapechar="~"; options papersize=(15cm 10cm); options topmargin=0cm bottommargin=0cm leftmargin=0cm rightmargin=0cm; ods pdf file="Carte.pdf" notoc newfile=Bygroup;
data _null_; set sashelp.class; by name;
if _N_=1 then do; declare odsout obj(); end;
obj.open_dir(name: name, label: "", by: 1);
obj.layout_absolute(overrides: "borderwidth=1"); obj.region(width: "15cm", height: "2cm", overrides: "background=cx494068"); obj.format_text(data: "Groupe Scolaire L. Aragon", overrides: "color=cxbbb2e0 font_size=32pt", just: 'c');

 

Thank you !

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

Hi:

  When you use NEWFILE=BYGROUP the behavior of ODS is to make numbered files, one increment for each by group value. If you want to do something that is data-driven so that the name of the student (or any other data driven value) is used in the FILE= option, you need to investigate using SAS macro variables and/or a SAS macro program. There have been examples of this posted in the past in the forums, so a search should help you find some of those examples.

Cynthia

View solution in original post

2 REPLIES 2
Cynthia_sas
Diamond | Level 26

Hi:

  When you use NEWFILE=BYGROUP the behavior of ODS is to make numbered files, one increment for each by group value. If you want to do something that is data-driven so that the name of the student (or any other data driven value) is used in the FILE= option, you need to investigate using SAS macro variables and/or a SAS macro program. There have been examples of this posted in the past in the forums, so a search should help you find some of those examples.

Cynthia

SASdevAnneMarie
Barite | Level 11
Thank you Cynthia,
That works !

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 2 replies
  • 819 views
  • 1 like
  • 2 in conversation