It's not clear from your question what you are trying to acheive - you say in the comments that you are looking to select a variable width, but your code example (even if it compiled) would always be trying to access a 7-bit amount from data. In that case @Light's answer would be the way forward.
However based on the name of your module, and signal names, I'm going to hazard a guess that what you are actually trying to accomplish is a simple bit-shift, setting the out_data to a specific part of the data bus. In this case, you can simply use the bit-shift operator:
assign out_data = data >> r_count;
I've assumed right shift there (based on the name r_count), but you could equally use left shift (<<) or arithmetic right shift (>>> - sign extending shift for 2's complement).
You may get warnings about truncation, in which case you can either ignore the warning, or add an intermediate step:
wire [31:0] data_rshift;
assign data_rshift = data >> r_count;
assign out_data = data_rshift[20:0];
data[r_count-1+:7]). If you want a variable width, you'd have to more accurately describe what you want with a matching example (even invalid). In any case, variable width is not possible (think about the hardware, a data bus couldn't suddenly become wider - where would the hardware come from). – Tom Carpenter Sep 11 '23 at 12:59