Help using Base SAS procedures

logical statement into Proc Report ods

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

logical statement into Proc Report ods

[ Edited ]

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

Attachment

Accepted Solutions
Solution
‎01-27-2018 03:27 PM
SAS Super FREQ
Posts: 9,365

Re: logical statement into Proc Report ods

Posted in reply to luciacossaro

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


All Replies
Solution
‎01-27-2018 03:27 PM
SAS Super FREQ
Posts: 9,365

Re: logical statement into Proc Report ods

Posted in reply to luciacossaro

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;
 
Contributor
Posts: 27

Re: logical statement into Proc Report ods

[ Edited ]
Posted in reply to Cynthia_sas

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

SAS Super FREQ
Posts: 9,365

Re: logical statement into Proc Report ods

Posted in reply to luciacossaro

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

Contributor
Posts: 27

Re: logical statement into Proc Report ods

Posted in reply to Cynthia_sas

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

 

 

 

 

SAS Super FREQ
Posts: 9,365

Re: logical statement into Proc Report ods

Posted in reply to luciacossaro
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
Contributor
Posts: 27

Re: logical statement into Proc Report ods

Posted in reply to Cynthia_sas

Excellent! thanks you very much for all.

Best regards

Lucia

SAS Super FREQ
Posts: 9,365

Re: logical statement into Proc Report ods

Posted in reply to luciacossaro

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

Contributor
Posts: 27

Re: logical statement into Proc Report ods

Posted in reply to Cynthia_sas

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

 

Have a excellent journey!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 296 views
  • 3 likes
  • 2 in conversation