BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

data test (keep=ln_no BO_BORR_FST_NM

     BO_BORR_LAST_NM BO_BORR_MDL_NM BO_BORR_NM YE_BORR_ID_NO);

     set data1;

     if ye_borr_id_no in ('9897'

                                '4231'

                                '6240'

                                '3708'

                                '9517');run;

Is there an alternative process to include all of the numbers in quotes without having to physically place quotes between all values.  For example '9897'.  I have about 900 of these to place after the ye_borr_id_no.  I know I can do a table using cards like this

data test;

input id_no $4.;

cards:

9897

etc........;

run;

I just need to perhaps incorporate this into the datastep.

4 REPLIES 4
slchen
Lapis Lazuli | Level 10

Use quote function

Reeza
Super User

Create the table test and use a SQL query instead:

proc sql;

create table want as

select *

from data1 where ye_borr_id_no in (select  id_no from test);

quit;

Tom
Super User Tom
Super User

For 900 you are better off using a data set and using SQL or MERGE to do the sub setting.

But if you want to generated quoted list from space delimited list than TRANWRD can help.

%let list=9897 4231 6240 ;

%let qlist="%sysfunc(tranwrd(&list,%str( )," "))";

%put &qlist;

ballardw
Super User

And yet another way:

proc format library=work;
value $mylist
9897,
4231,
6240,
3708   = 'Valid'
;
run;

data _null_;
do x= '9897','5555';
if put(x,$mylist.)='Valid' then put 'In list';
else put 'not in list';
end;
run;

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1845 views
  • 0 likes
  • 5 in conversation