Here is one possible solution:
@echo off
color 0a
echo.
echo.
echo Please insert the following
echo.
echo.
echo.
set /p _username=name:
set /p yearsoflife=age:
(echo=%_username%) > name.txt
(echo=%yearsoflife%) > yourage.txt
You were not so clear in your question; you referenced that you want both variable contents in one textfile. So, for this you can try (double the > symbol):
@echo off
color 0a
echo.
echo.
echo Please insert the following
echo.
echo.
echo.
set /p _username=name:
set /p yearsoflife=age:
(echo=%_username%) >> your_name.txt
(echo=%yearsoflife%) >> your_name.txt
Note: Change of set /p username=name: line was just not to confuse this username variable with username environment variable!
(Echo=%username%)>"name.txt",(Echo=%yearsoflife%)>"yourage.txt".(Echo=%username%,%yearsoflife%)>"file.txt", thanks for your help !