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

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;
1 ACCEPTED SOLUTION

Accepted Solutions
5 REPLIES 5
Shmuel
Garnet | Level 18

 

 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.

acordes
Rhodochrosite | Level 12

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. 

Reeza
Super User
If you want a wide dataset at the end, add a proc transpose, but IME it’s easier to work with it in the long form.
acordes
Rhodochrosite | Level 12

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...

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 990 views
  • 0 likes
  • 3 in conversation