BookmarkSubscribeRSS Feed
Aman4SAS
Obsidian | Level 7

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

7 REPLIES 7
Reeza
Super User

Do you know how to create macro variables?

Aman4SAS
Obsidian | Level 7

yes, %let n call symput();

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

Reeza
Super User

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.

Aman4SAS
Obsidian | Level 7

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.

Reeza
Super User

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.";

Aman4SAS
Obsidian | Level 7

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.

Reeza
Super User

footnote;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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