Hello,
I need help on how to subtract one column from another in SAS VA.
I need another column next to the TEKUCI one that will be the difference = PRETHODNI - TEKUCI.
Or in this case below, another row, under TEKUCI, whic will be equal PRETHODNI - TEKUCI
Is this even possible? I didn't find anywhere any solution.
Hi @tijanagilic,
as this is an important feature I link the documentation of calculated items, with which you could define a Difference column.
SAS Help Center: Working with Calculated Items in a Report
Best
Markus
Hi @tijanagilic,
as this is an important feature I link the documentation of calculated items, with which you could define a Difference column.
SAS Help Center: Working with Calculated Items in a Report
Best
Markus
I think there's going to be a problem though in how @tijanagilic wants to display this. Getting the calculated value isn't going to be too difficult, but displaying it as another row/column after TEKUCI I don't think is possible. You can only create it as a new measure, which means it will show up as a column next to # (and thus appear twice in the crosstab, once for PRETHODNI and once for TEKUCI) rather than next to TEKUCI as a single column.
I don't know what the column is called that contains both PRETHODNI and TEKUCI so I'm just going to call it Column but what I might recommend doing to get the visual you want is the following:
1. Create two new calculated items to represent the value of # for both PRETHODNI and TEKUCI:
If Column IN (PRETHODNI)
RETURN #
ELSE 0
and
If Column IN (TEKUCI)
RETURN #
ELSE 0
Now you have two new measures, we'll say Prethodni # and Tekuci #.
2. Create a third calculated item for the difference:
Prethodni # - Tekuci #
3. In your crosstab, take out Column and #, and instead use the three new measures we created.
If I've misunderstood something though let me know.
Maybe I missed that the two columns are in a crosstab and not original data columns.
It worked!
Thank you! 😊
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.