Hi Everyone,
------ good code----
data want; set have;
array v[*] var:;
if min(of v[*])<0 then do;
do i=1 to dim(v);
if v[i]<0 then do;
output_name=row;
output_column = vname(v[i]);
output;
end;
end;
end;
run;
------
For each negative value in my table, I need to keep track of the name of row ("name") and the name of column and the value itself.
My output data should look like that
output_row | output_column | value
loc1 | var2 | -3
loc2 | var2 | -4
loc2 | var3 | -55
Can anyone please help?
Thank you,
HHCFX
data have; input row $ var1 var2 var3;
datalines;
loc1 2 -3 9
loc2 4 -4 -55
loc3 4 5 6
run;
*I think it can be the approach;
data want; set have;
array v[*] var:;
do i=1 to dim(v);
if v<0 then do;
output_name=row;
output_column= turn column name to text;
output;
end;
end;
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.