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

Hi, 

 

I have a data base with invoices, taxes and costumer information and I need to get a pdf file for each invoice. I'm trying to get a pdf file with a Proc Report statement but i have a bug with the logical statement (IF.First facture THEN do). I need help to know where i should place it (i'm a new sas's user). I would be very grateful.

 

I attach the code and the result expecting.

 

Lucia

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  The type of report you show can be done; however, not the way you have coded.

not_work_report.png

 

For starters, you can only have 1 COLUMN statement in PROC REPORT. While you could control the COLUMN statement for each customer in a Macro program, I do not think you need one here. I would write the name, address in a COMPUTE before block and then instead of calculating TOTAL yourself, let PROC REPORT generate the total. Something like this. I didn't bother with Monospace style or fonts because the font looked OK to me. Also, I'm not sure where you got your 31,12 for the line under the summary, because I did not see it in your data.

example_invoice.png

 

Here's the code I used. I did a bit of data manipulation on your TABLEFINAL data, everything else was the same as you posted in your example code.

 

cynthia

 


title; footnote;
data final2;
  length namestr $300;
  set tablefinal;
  fullname = catx(' ',Cvl,Prenom,Nom);
  fullcity = catx(' -- ',Code_postal,Ville);
  namestr=catx('^{newline 1}',fullname,Adresse,fullcity);
run;

options nodate nonumber orientation=portrait 
        nobyline leftmargin=2in rightmargin=1.25in;
ods escapechar='^';
ods pdf file='c:\temp\aaa.pdf' style=journal notoc;
title j=l 'Societe MEE' j=r "&sysdate9" ;
title2 j=l "Material d'experts economiques";
title3;
title4 j=l 'Facture numero #byval1';
  

proc report data=final2 nowd
     style(report)={frame=void width=100%};
  by Facture;
  column Facture namestr Produit Descriptif Prix_HT TVA  Q  TTC ;
  define Facture / order f=12. page noprint;
  define namestr / order noprint;
  define Produit / order 'Produit' style(header)={just=r};
  define Descriptif / display 'Description';
  define Prix_HT / display 'Prix_HT' style(header)={just=r};
  define TVA / display  'TVA'style(header)={just=r};
  define Q / display 'Quantité' style(header)={just=r};
  define TTC / sum 'TTC' style(header)={just=r} f=commax12.2;
  break after facture / summarize page;
  compute before _page_ / style=SystemTitle{just=r};
     line namestr $varying300.;
  endcomp;
  compute after facture / style=Header{just=l};
    length aftline $200;
    aftline = catx(' ','Total arrete a', put(TTC.sum, commax12.2),'toutes taxes comprises, incluant 31,12 de TVA.');
    line aftline $varying200.; 
    line ' ';
    line 'En votre aimable relement par retour de courrier.';
  endcomp;

RUN ;
ods pdf close;
 

View solution in original post

8 REPLIES 8
Cynthia_sas
SAS Super FREQ

Hi:

  The type of report you show can be done; however, not the way you have coded.

not_work_report.png

 

For starters, you can only have 1 COLUMN statement in PROC REPORT. While you could control the COLUMN statement for each customer in a Macro program, I do not think you need one here. I would write the name, address in a COMPUTE before block and then instead of calculating TOTAL yourself, let PROC REPORT generate the total. Something like this. I didn't bother with Monospace style or fonts because the font looked OK to me. Also, I'm not sure where you got your 31,12 for the line under the summary, because I did not see it in your data.

example_invoice.png

 

Here's the code I used. I did a bit of data manipulation on your TABLEFINAL data, everything else was the same as you posted in your example code.

 

cynthia

 


title; footnote;
data final2;
  length namestr $300;
  set tablefinal;
  fullname = catx(' ',Cvl,Prenom,Nom);
  fullcity = catx(' -- ',Code_postal,Ville);
  namestr=catx('^{newline 1}',fullname,Adresse,fullcity);
run;

options nodate nonumber orientation=portrait 
        nobyline leftmargin=2in rightmargin=1.25in;
ods escapechar='^';
ods pdf file='c:\temp\aaa.pdf' style=journal notoc;
title j=l 'Societe MEE' j=r "&sysdate9" ;
title2 j=l "Material d'experts economiques";
title3;
title4 j=l 'Facture numero #byval1';
  

proc report data=final2 nowd
     style(report)={frame=void width=100%};
  by Facture;
  column Facture namestr Produit Descriptif Prix_HT TVA  Q  TTC ;
  define Facture / order f=12. page noprint;
  define namestr / order noprint;
  define Produit / order 'Produit' style(header)={just=r};
  define Descriptif / display 'Description';
  define Prix_HT / display 'Prix_HT' style(header)={just=r};
  define TVA / display  'TVA'style(header)={just=r};
  define Q / display 'Quantité' style(header)={just=r};
  define TTC / sum 'TTC' style(header)={just=r} f=commax12.2;
  break after facture / summarize page;
  compute before _page_ / style=SystemTitle{just=r};
     line namestr $varying300.;
  endcomp;
  compute after facture / style=Header{just=l};
    length aftline $200;
    aftline = catx(' ','Total arrete a', put(TTC.sum, commax12.2),'toutes taxes comprises, incluant 31,12 de TVA.');
    line aftline $varying200.; 
    line ' ';
    line 'En votre aimable relement par retour de courrier.';
  endcomp;

RUN ;
ods pdf close;
 
luciacossaro
Obsidian | Level 7

Thanks you very much for you clarifying and complete answer, it help me so much. The 31.12 is a variable too, i get it multiplying "TVA" for "q" for each product and adding the result for each invoice. I going to include this varaible in the tablefinal data  and i going to includ it into the attributes of "aftline=".

 

Best regards

Cynthia_sas
SAS Super FREQ

Hi:

  Ah, that makes sense. So my approach, since you need a DATA step anyway to make NAMESTR is to just add a new variable there. Something like this:


title; footnote;
data final2;
  length namestr $300;
  set tablefinal;
  fullname = catx(' ',Cvl,Prenom,Nom);
  fullcity = catx(' -- ',Code_postal,Ville);
  namestr=catx('^{newline 1}',fullname,Adresse,fullcity);
  tout_tax = q*tva;
run;

options nodate nonumber orientation=portrait 
        nobyline leftmargin=2in rightmargin=1.25in;
ods escapechar='^';
ods pdf file='c:\temp\aaa.pdf' style=journal notoc;
title j=l 'Societe MEE' j=r "&sysdate9" ;
title2 j=l "Material d'experts economiques";
title3;
title4 j=l 'Facture numero #byval1';
  

proc report data=final2 nowd
     style(report)={frame=void width=100%};
  by Facture;
  column Facture namestr Produit Descriptif Prix_HT TVA  Q  TTC tout_tax;
  define Facture / order f=12. page noprint;
  define namestr / order noprint;
  define Produit / order 'Produit' style(header)={just=r};
  define Descriptif / display 'Description';
  define Prix_HT / display 'Prix_HT' style(header)={just=r};
  define TVA / display  'TVA' style(header)={just=r};
  define Q / display 'Quantité' style(header)={just=r};
  define TTC / sum 'TTC' style(header)={just=r} f=commax12.2;
  define tout_tax / sum f=commax12.2 noprint;
  break after facture / summarize page;
  compute before _page_ / style=SystemTitle{just=r};
     line namestr $varying300.;
  endcomp;
  compute after facture / style=Header{just=l};
    length aftline $200;
    aftline = catx(' ','Total arrete a', put(TTC.sum, commax12.2),'toutes taxes comprises, incluant', put(tout_tax.sum,commax12.2), 'de TVA.');
    line aftline $varying200.; 
    line ' ';
    line 'En votre aimable relement par retour de courrier.';
  endcomp;

RUN ;
ods pdf close;
 

I used the Journal style because it is a very nice, clean style.

 

cynthia

luciacossaro
Obsidian | Level 7

Thanks you very much! I've added the TVA variable in the bottom of report. It's possible to add the Euro symbol after the numbers in the column TTC ? K

I'added it in 

aftline = catx(' ','Total arrete a', put(TTC.sum, commax12.2),'toutes taxes comprises, incluant', put(tout_tax.sum,commax12.2), 'de TVA.');

but the € overwtrites the number if i put € in the defines, i get the bugs.

 

I'm agree hhe journal style is very nice.

 

Lucia

 

 

 

 

Cynthia_sas
SAS Super FREQ
I think there is a EURO format that will put the symbol in for you. You would use that format instead of the COMMAX. Not sure whether it is EURO or EUROX, but you should be able to find it in the doc.

cynthia
luciacossaro
Obsidian | Level 7

Excellent! thanks you very much for all.

Best regards

Lucia

Cynthia_sas
SAS Super FREQ

Hi:

  The EUROX format worked for me, as shown below:

use_eurox.png

 

Although this Tech Support note http://support.sas.com/kb/56/238.html mentions another format.

 

cynthia

luciacossaro
Obsidian | Level 7

It's works. Thanks you very much for all answer, you've helped me so much.

 

Have a excellent journey!

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 8 replies
  • 1430 views
  • 3 likes
  • 2 in conversation