Control output pins using 8-bit number

const  byte pins [8] = {2, 3, 4, 5, 6, 7, 8, 9};

void setup() {
  Serial.begin(9600);
}

void loop() {
  byte p = analogRead(0) / 4;
  for (int i = 0, unsigned byte mask_bit = 1; i < 8; ++i, mask_bit<<=1) {  {
    digitalWrite(pins [i],  !!(p & mask_bit));
  }
}

You should be aware that because you're not writing the DAC in a single operation, the output will wander around a bit, though if you're driving it with a pot, you probably won't notice this.