\set
is a feature of psql (the interactive command line terminal) and not available in pgAdmin.
PostgreSQL does not normally use variables in plain SQL. You would use PL/pgSQL code in an anonymous block (DO
statement) or in a function.
However, you can (ab)use customized options, for server-side "variables", independent of the client in use:
SET foo.test = 'SELECT bar FROM baz';
SELECT current_setting('foo.test');
Details in this related answer:
There was also pgScript, a local scripting extension of the pgAdmin3 query tool, where you could use local variables, comparable to what you can do in psql. The manual:
You can run pgScript scripts by selecting Execute pgScript from the
Query menu instead of Execute, or you press the Execute pgScript
toolbar button, or you press the F6 function key.
But pgAdmin3 is unmaintained now, and pgAdmin4 does not include pgScript. Wasn't all that useful.