In magento 2 Attribute is create using Setup file. If we need to install the data in the system (database) create InstallData.php file in Setup folder so path should be

app/code/<package name>/<module name>/Setup/InstallData.php

In the InstallData.php we need to create class for module.We need to add the below content to create attribute.