BookmarkSubscribeRSS Feed
UPRETIGOPI
Obsidian | Level 7

Hi

I need some help on SAS macro. Let me state the problem.

 

I have a data table that has name, date, salary columns. The salary is missing for some names in some dates. I would like to produce a report in which I want to include the footnote that says "Salary is missing for Name=&name in date=&date.

Here is the sample data table

 

Name Date Salary

Robert 01Feb2017 5000

Shyam 01Mar2017 2000

Dinesh 01May2017 3000

Shou 01Jul2017  .

Rishi 01Sep2017 4000

Noral 01Dec2017 .

;

Please help me on this. Thanks

2 REPLIES 2
ThierryHerrie
Obsidian | Level 7

You mean something like this?

proc sql noprint ;
  select 'Name='||strip(name)||' in date='||strip(put(date,date9.)) INTO:footer separated by ' '
  from dataset
  where salary is missing ;
quit ;

footnote "Salary is missing for &footer." ;
proc print data=dataset ;
run ;
Shmuel
Garnet | Level 18

I don't think that FOOTNOTE is the right place in a report to list all names with missing salary,

unless you are sure there are less than 10 names. You better create two reports:

 

title ' Salary given to';

proc print data=have (where=(salary ne .));  /* optiona NOOBS */

var name date salary;

sumvar salary;

run;

 

title "Nmaes with missing salary";

proc print data=have(where=(salary is missing));

var name date;

run;

 

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!

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.

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