Hi everyone, I'm about to cry because of SAS! I feel like I'm going crazy! Here's my issue: I want to create variables to flag specified keywords that are found in a TOPIC variable. Here's the code that I have: data test ;
format topics $char256. ;
infile datalines dsd dlm=":";
input topics $ ;
datalines;
PHYSICAL COMPUTING BASIC COMPUTER TEACHING PROJECTS USING WORD PROCESSING AND DATA ANALYZING POWERPOINT
GAME DESIGN
WEB DESIGN AND DEVELOPMENT MOBILE APP DEVELOPMENT
PHYSICAL COMPUTING MAKER ACTIVITIES WEB DESIGN AND DEVELOPMENT TEXT-BASED PROGRAMMING
;
run;
%macro test() ;
DATA test ;
SET test ;
array keywords [6] $ t1-t6 ('PHYSICAL', 'ACTIVITES', 'GAME', 'DATA', 'CODING', 'MOBILE') ;
array varnames [6] physcomp makeract gamedesign datasci coding mobiledev ;
%do i = 1 %to 6 ;
if findw(topics, keywords[&i]) > 0 then varnames[&i] = 1 ;
else varnames[&i] = 0 ;
%end ;
RUN ;
%mend ;
%test() ; which produces the following data: PHYSICAL COMPUTING BASIC COMPUTER TEACHING PROJECTS USING WORD PROCESSING AND DATA ANALYZING POWERPOINT
1 0 0 0 0 0
GAME DESIGN
0 0 0 0 0 0
WEB DESIGN AND DEVELOPMENT MOBILE APP DEVELOPMENT
0 0 0 0 0 0
PHYSICAL COMPUTING MAKER ACTIVITIES WEB DESIGN AND DEVELOPMENT TEXT-BASED PROGRAMMING
1 0 0 0 0 0 Huh? Why isn't GAME in the second observation being recognized? Or MOBILE in the third observation? Why is PHYSICAL the only keyword being recognized? Please help, I'm at my wit's end!!!
... View more