I put all read emails to trash on samsung, ipad and iphone but keep on imac and wish to retain there for reference. All other accounts remain but icloud emails disappear. No devices say to delete from server.
If this is your iCloud email account, whcn you delete an email from any of your devices, they are moved to the trash on all devices/computers, then the trash is automatically deleted after 30 days. That's how IMAP accounts work. You can't delete them from your device and keep it on the server because you are reading and deleting from the server itself.
If you want to keep them on your Mac, you'll need to move them to a folder rather than deleting them. When you do, they will be moved to the same folder on your other devices.
I recently had the same problem. I went looking for an email on my iCloud account older than 30 days, and couldn't find it. I mainly use mac mail but also my iPad.
I found a solution in another post some where that may be useful to you.
Open your iCloud mail, not mac mail. setup a folder, I called mine 'deleted server mail'. Then in settings, change the setting delete after 30 days, and move to 'deleted server mail' folder. This way you can delete when you want. I normally keep mine 12 months and delete at 6 month intervals.
I hope this helps. Another thing you can do is contact apple through their mail suggestions page and ask them to change their options on 'delete from server' to include never. If enough people do this then surely they may take notice.