I have parsed every sentence to its words.
I use an array for this task, I overestimate the number of elements necessary.
Once done I want to drop those overhanging variables created by the array.
I know how to address this problems in many ways like building a macro variable via proc sql or symputx and use it in the drop statement.
but all ideas require at least one more data step.
so I thought why not use the vname function to feed the drop statement at the end.
But it doesn't work
data WORK.test3;
set WORK.test2 end=eof;
where bastidor ne "";
array parsed_txt(100) $200;
retain maxi;
i=1;
do while(scan(texto, i, " ") ne "");
parsed_txt(i) = strip(scan(texto, i, " "));
i+1;
maxi=max(i,maxi);
end;
if eof then do;
do j=maxi to 100;
temp= vname(parsed_opt(j));
drop parsed_opt1;
end;
end;
drop i maxi;
run;
Statements like DROP KEEP RENAME LENGTH FORMAT etc. - are declarations in a data step
not executable through run. ( I hope my English is clear enough).
While running data step sas writes all variables to output according to declarative statements.
You can't drop variables after they have been already written to output but in a separate step by
copying data and keep selected variables only, defined by KEEP, DROP or RENAME satements.
Thanks, if I write out the overhanging and empty variables explicitly after the drop statement, the code works and the result is what I want.
But it seems that I cannot hand over to the drop statement a concatenated string that once resolved is a variable name and therefore should be interpreted like this by the drop statement.
I took the data to long format afterward and I achieve what I planned to (reading this data set into IML and run a SVD, filter for the 10 most relevant eigenvalues and its dominant members in the V matrix where the words come into play(.
But often I have the feeling that I could have solved a given theme in a more efficient manner. Your link to the sentence-to-words code is fine. I thought that I could use VNAME for this purpose in runtime.
I haven't discovered yet the usefulness of VNAME or VVALUEX functions...
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.