keep and name a sensor value

hello,

for my project I want to keep and name a variable value at the start of the program. so I can subtract it later.
maybe it is a dumb question, but I could not find it anywhere online.

Define your variable as a global, and do the initialisation in the setup function

You can also a static variable declared in the relevant function:

float read_sensor ()
{
  static float sensor_baseline = -999 ; // some flag value at program start
  float value = ...... ; // read the sensor
  if (baseline == -999)  // first time called record the baseline - assumes -999 is not a valid sensor reading
    baseline = value ;
  return value - baseline ;
}

Keeping a static variable with local scope like this is neater than having a global. Note that such
a static has only one copy that lives the life of the program, which is why this works. The function
is self-contained and you don't need to remember to do anything in setup()

I've deleted your other cross post @BoasdeLely.

Cross posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes writing a detailed answer on this thread, without knowing that someone else already did the same in the other thread.

Repeated cross posting will result in a suspension from the forum.

In the future, please take some time to pick the forum section that best suits the topic of your question and then only post once to that forum section. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum section. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.