DATA Step, Macro, Functions and more

title with macro

Reply
Super Contributor
Posts: 265

title with macro

Hi,

i have data set like:

data test;

input name $ PAID_status $;

datalines;

AMAN Y

PAWAN Y

KUMAR N

TIWARI Y

MINU N

DEEPAK N

RAHUL Y

VISHAL N

POOJA Y

PAYAL Y

goyal N/A

BALAK N

;

RUN;

now i m looking to generate report like :

report of 11 student

Name         paid_status

AMAN           Y

PAWAN        Y

KUMAR        N

TIWARI         Y

MINU            N

DEEPAK       N

RAHUL          Y

VISHAL         N

POOJA         Y

PAYAL          Y

BALAK         N

6 student paid and 5 student not paid out of 11 student.

PLZ HELP

Super User
Posts: 17,912

Re: title with macro

Do you know how to create macro variables?

Super Contributor
Posts: 265

Re: title with macro

yes, %let n call symput();

but not able to use logic how to use it here..

Super User
Posts: 17,912

Re: title with macro

Try doing it via proc sql:

http://www.ats.ucla.edu/stat/sas/library/nesug99/cc107.pdf

The trick is to get the summary values you need and then use those to create the macro variables.

You could do it multiple ways:

1) one sql step

OR

2) Use proc means to get the output with the total and count for each group and use that data set and call symput to create your macro variables.

Super Contributor
Posts: 265

Re: title with macro

count n total is nt a prob for me , i hav done that already.

DATA TEST1;

SET TEST END = FINAL;

IF STATUS = 'Y' THEN Y+1;

IF STATUS= 'N' THEN N+1;

TOT+1;

RUN;

PROC PRINT;

RUN;

main prob is using that in title n footnote.

Super User
Posts: 17,912

Re: title with macro

Create macro variables with call symput using your data then.

DATA TEST1;

SET TEST END = FINAL;

IF STATUS = 'Y' THEN Y+1;

IF STATUS= 'N' THEN N+1;

TOT+1;

if final then do;

     call symput('num_yes', y);

call symput('num_no', n);

end;

RUN;

title "num of yes: &num_yes. and number of no: &num_no.";

Super Contributor
Posts: 265

Re: title with macro

DATA TEST1;

SET TEST END = FINAL;

IF STATUS = 'Y' THEN Y+1;

IF STATUS= 'N' THEN N+1;

TOT+1;

if final then do;

     call symput('num_yes', y);

call symput('num_no', n);

call symput('Tot',tot);

end;

RUN;

proc print;   

title "&num_yes. student are paid and %sysfunc(left(&num_no.)) students are not paid out of: %sysfunc(left(&tot.)) students";

run;

Thanks.. one more thing plz let me know how to reset footnote.  i m nt giving any footnote in my code but still its giving last footnote.

Super User
Posts: 17,912

Re: title with macro

footnote;

Ask a Question
Discussion stats
  • 7 replies
  • 215 views
  • 3 likes
  • 2 in conversation