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

 

data have;
input ID $ Q12 $15.;
cards;
1 1,2,3,4,5
2 4,11,13
3 6,7,8,9,10,11
4 .
5 1,19
6 .
;
run;

data want;
	set have;
	len=length(Q12);
	array q[*] Q1-Q6;

	do i=1 to len;
		call scan(Q12,i,pos,ln,',');

		if not pos then
			leave;

		if input(substrn(q12,pos,ln),8.) then
			q[i]=1;
	end;

	do j=1 to dim(q);
		if missing(q[j]) then
			q[j]=0;
	end;

	drop pos ln i len j;
run;

AI Navigator GIF.gif


Navigate AI governance with SAS tools for compliance and ethical AI practices. Try SAS Ai Navigator for free for the first six months.

Check it out on Microsoft Marketplace →

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
  • 15 replies
  • 6432 views
  • 2 likes
  • 4 in conversation