macros - Creating prompt for missing and nonmissing -


i trying add prompt missing or nonmissing options. code doesn't work ,need fix that. rec_and_issues new table created in report. need pick rec_and_issues.sfvfdbk_feedback_comments missing or not.

 %macro missing_or_nonmissing; %if "&sel_issue" eq "missing" %then %do; data rec_and_issues; set rec_and_issues;   rec_and_issues.sfvfdbk_feedback_comments null; run; %end;  %else %if "&sel_issue" eq "nonmissing" %then %do; data rec_and_issues;  set rec_and_issues; rec_and_issues.sfvfdbk_feedback_comments not null; run;   %end; %mend missing_or_nonmissing; 

you shouldn't put data step inside macro. how decide depends on style - not include where in macro if it's avoided, makes easier read , understand code - variation on should fine. put parts of datastep in macro vary.

%macro missing_or_nonmissing(sel=);   %let not = %sysfunc(ifc(&sel=nonmissing,not,));   svfdbk_feedback_comments &not. null %mend missing_or_nonmissing;  data rec_and_issues;   set rec_and_issues;   %missing_or_nonmissing(sel=&sel_issue) ; run; 

no reason beyond that. further, if using parameter, use parameter. global variables shouldn't used inside macro in cases, , not in case it's parameter macro.

further, don't need @ all. if solely filtering dataset, can whenever use dataset (or when created, depending on how created). example, if next step proc sort, is, should in proc sort - , macro lets that. (this why leave where out of - since syntax differs in data set options).

proc sort data=rec_and_issues(where=(%missing_or_nonmissing(sel=&sel_issue.))); idvar; run; 

finally, if you're 1 creating prompt, recommend having underlying values 1/0 not text. way don't have worry upcase/etc., , can use them bit more (since 1 'true' , 0 'false').


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -