This is from the DATA Manipulation Course 9.4 Base Programming.
Please explain the use of the put function in this activity.
Open p204a03.sas from the activities folder and perform the following tasks:
BasinGroup=put(Basin, $region.);
PUT writes the value of BASIN using the $REGION format and assigns this value to variable BASINGROUP.
So if BASIN contains value 'NA' then BasinGroup contains the value 'Atlantic'. I don't know what "no conversion" in your title means; here 'NA' is, in a manner of speaking, converted to 'Atlantic'.
In the other code, where there is no PUT statement, the format $REGION is applied to variable BASINGROUP, and so the value 'NA' remains the value, but you see 'Atlantic'. (Please note that in the other code with the PUT statement, BASINGROUP has value 'Atlantic') That's what formats do, they change the appearance, but do not change the underlying value.
So, why use PUT? To change the actual value; using a format does not change the actual value, formats change the appearance of the value. This can make a difference in sorting, if you want a specific sort order, the two possibilities could sort differently. There are probably other reasons as well, but without knowing the real use of this data (because this is a contrived example), I can't be more specific.
Please post code inside a code box as I did above; please click on the "little running man" icon to open a code box.
Formats convert values into text. Numeric formats convert numbers into character string. Character formats convert character strings into (possibly different) character strings.
Informats convert text into values. Numeric informats convert character strings into numbers. Character informats convert character strings into (possibly different) character strings.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.