BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AshleyM
Fluorite | Level 6

I'm trying to generate a stored process that allows end users to select more than one "NOS" code, while also selecting a specific date range. However, happens when I run the stored process.  

libname IDB "/res/IDB/updates";

%macro noslist;

%global nos0;

/* If more than one nos value was selected then cycle through the values */

    %if %eval(&nos0 ge 2) %then %do;

          %do i=1 %to &nos0;

            &&nos&i

          %end;

    %end;

/* If only one nos value was selected  */

     %else &nos

%mend noslist;

%stpbegin;

  data test;

         set idb.cv00on; 

           /* Keep the observation ONLY if the following conditions are True  */

         if (filedate >= "&FILEDATE_MIN"d and filedate <= "&FILEDATE_MAX"d) then;

         if nos in(%noslist);  

  run;

  %stpbegin;

     proc print data=test;

     run;

  %stpend;

I can generate output with a single value for NOS, but agin, not with multiple values.

libname IDB "/res/IDB/updates";

data work.test;

        set idb.cv00on; 

           where (NOS = &NOS) and (filedate between "&FILEDATE_MIN"d and "&FILEDATE_MAX"d);

      run;

      %stpbegin;

         proc print data=work.test;

         run;

      %stpend;

1 ACCEPTED SOLUTION

Accepted Solutions
NN
Quartz | Level 8 NN
Quartz | Level 8

Hi,

Can you check and see if this works for you ... Cannot Test at my end right now...


%stpbegin;
libname IDB "/res/IDB/updates";

%macro data();
data work.test;
set idb.cv00on; 
where
(NOS in
(
%DO I = 1 %TO &NOS_COUNT;
%if &i =1 %then %do;
&nos
%end;
%else %do;
&&nos&i
%end;
%END;
)
)
and (filedate between "&FILEDATE_MIN"d and "&FILEDATE_MAX"d);
run;
%mend;
%data
proc print data=work.test;
run;
%stpend;

View solution in original post

2 REPLIES 2
NN
Quartz | Level 8 NN
Quartz | Level 8

Hi,

Can you check and see if this works for you ... Cannot Test at my end right now...


%stpbegin;
libname IDB "/res/IDB/updates";

%macro data();
data work.test;
set idb.cv00on; 
where
(NOS in
(
%DO I = 1 %TO &NOS_COUNT;
%if &i =1 %then %do;
&nos
%end;
%else %do;
&&nos&i
%end;
%END;
)
)
and (filedate between "&FILEDATE_MIN"d and "&FILEDATE_MAX"d);
run;
%mend;
%data
proc print data=work.test;
run;
%stpend;

AshleyM
Fluorite | Level 6

Thank you! This worked Smiley Happy

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 826 views
  • 0 likes
  • 2 in conversation