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

proc sql noprint;
select distinct strip(VARIABLE) into :commonrs separated by ', ' ,
distinct strip(VARIABLE) into :commonvrg separated by ' '
from COMMON;
quit;

 

I am using the above code, just to make sure before sending test data as i get syntax error, can anyone help me figure out where the issue was.

distinct strip(VARIABLE) into :commonvarsmrg separated by ' ' from COMMON;
--------
79
76

ERROR 79-322: Expecting a :.

ERROR 76-322: Syntax error, statement will be ignored.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

You can only use DISTINCT once, it applies to all variables.

 

Also,

 

select distinct strip(VARIABLE1),strip(VARIABLE2)
    into :commonrs separated by ', ' ,:commonvrg separated by ' '
from COMMON;
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You can only use DISTINCT once, it applies to all variables.

 

Also,

 

select distinct strip(VARIABLE1),strip(VARIABLE2)
    into :commonrs separated by ', ' ,:commonvrg separated by ' '
from COMMON;
--
Paige Miller
ErikLund_Jensen
Rhodochrosite | Level 12

Hi @vraj1 

 

Select and into are separate statements, each with a variable list, so the correct syntax should be:

 

proc sql noprint;
	select distinct
		strip(VARIABLE),
		strip(VARIABLE)
	into 
		:commonrs separated by ', ' ,
		:commonvrg separated by ' '
	from COMMON;
quit;

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2063 views
  • 2 likes
  • 3 in conversation