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;
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
  • 1075 views
  • 0 likes
  • 2 in conversation