Help using Base SAS procedures

Set a column of value as selection criteria to a data step

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

Set a column of value as selection criteria to a data step

Hi,

I generate a column of id (its variable name is c) from data set one (discrepancy_2016_2) and try to put it for data set two as IF/THEN criteria. Here is my example of code but it doesn’t work. Please advise. 

 

PROC SQL NOPRINT;

SELECT c INTO : cList

FROM discrepancy_2016_2

 ;

QUIT ;

 

 

data discrepancy_2016_last_2;

set discrepancies_20jun17;

IF case_no in "compress(&clist)";

run;

 

Thank you.


Accepted Solutions
Solution
‎06-06-2018 12:55 PM
PROC Star
Posts: 1,844

Re: Set a column of value as selection criteria to a data step

[ Edited ]

Try

if case no is char

PROC SQL NOPRINT;

SELECT quote(compress(c)) INTO : cList separated by ','

FROM discrepancy_2016_2

 ;

QUIT ;

 if caseno is numeric 

PROC SQL NOPRINT;

SELECT c INTO : cList separated by ','

FROM discrepancy_2016_2

 ;

QUIT ;

 

 

data discrepancy_2016_last_2;

set discrepancies_20jun17;

IF case_no in (&clist);

run;

 

 

View solution in original post


All Replies
Solution
‎06-06-2018 12:55 PM
PROC Star
Posts: 1,844

Re: Set a column of value as selection criteria to a data step

[ Edited ]

Try

if case no is char

PROC SQL NOPRINT;

SELECT quote(compress(c)) INTO : cList separated by ','

FROM discrepancy_2016_2

 ;

QUIT ;

 if caseno is numeric 

PROC SQL NOPRINT;

SELECT c INTO : cList separated by ','

FROM discrepancy_2016_2

 ;

QUIT ;

 

 

data discrepancy_2016_last_2;

set discrepancies_20jun17;

IF case_no in (&clist);

run;

 

 

Occasional Contributor
Posts: 10

Re: Set a column of value as selection criteria to a data step

Posted in reply to novinosrin

Hi,

 

Thank you for the code. IT works.

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 92 views
  • 0 likes
  • 2 in conversation