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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.