How do I get a block with data to place myself?

On a computer, you can do this with the “pick block” control, which defaults to the middle mouse button. Put your crosshair over the block you want to get and then press Ctrl + pick block, which will put that block with its data into your inventory. Of course, this will only work in creative mode.

Unfortunately, this cannot be done on touch devices without “Full Keyboard Gameplay” enabled, as there is no “pick block” control.

For more information on the “pick block” control, see Controls on the Minecraft wiki.