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.
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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.