BookmarkSubscribeRSS Feed
jmobball34
Calcite | Level 5

New SAS user here. I'm attempting to convert character values to numeric values using arrays. After the conversion, I would like to DROP all the fields that comprise my initial array (character values). Is there a way to drop only the variables that appear in my character values array?

 

data test;
	infile datalines delimiter=','; 
	input col1 $ col2 $ col3 $ oddball $;
	format col1--oddball $char100.;
	datalines;
1,2,0,a
2,3,0,b
3,4,0,c 
		;
run;

data test2;
	set test;

	format newCol1-newCol3 best.;

    array myarray Col1-Col3;
    array myNewarray newCol1-newCol3;
    do i=1 to dim(myarray);
           myNewarray[i]= input(myarray[i],best.);
    end;
    drop myarry[*];
run;

I'm receiving the error at the DROP statement.

1 REPLY 1
Reeza
Super User

I don’t think you can reference an array in the DROP statement, but you can list your variables the way you did in the array statement:

 

Drop col1-col3;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1 reply
  • 1008 views
  • 0 likes
  • 2 in conversation