BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zz
Calcite | Level 5 zz
Calcite | Level 5

How do I apply a YN. format to a variable in a sas dataset?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Most robust is usually when the data set is created if possible with a format statement.

If you aren't going to replace the version of the data set (are real sure you aren't) manually may work for you: open the dataset in table view click on the column heading and get the column properties, type the format name in the format box, apply and save.

Or from the Columns view of the data set from the explorer similar.

Or Proc Datasets will modify existing datasets

 

Proc datasets library=yourlib; /* put the name of the library where AE data set resides*/

   modify ae;

      format Serious YN.

   ;

   run;

quit;

 

Note that the procedure is one that supports multiple run statements so needs a quit; to actually end;

View solution in original post

3 REPLIES 3
zz
Calcite | Level 5 zz
Calcite | Level 5

I have a SAS dataset "AE".  There is a field "SERIOUS".  The format "YN." was missing.  If I need to apply the format "YN." to this "AE" dataset, what is the most straight forward and efficient way to apply "YN." format to the "SERIOUS" field in "AE" dataset.

 

 

Appreciate your help very much!

ballardw
Super User

Most robust is usually when the data set is created if possible with a format statement.

If you aren't going to replace the version of the data set (are real sure you aren't) manually may work for you: open the dataset in table view click on the column heading and get the column properties, type the format name in the format box, apply and save.

Or from the Columns view of the data set from the explorer similar.

Or Proc Datasets will modify existing datasets

 

Proc datasets library=yourlib; /* put the name of the library where AE data set resides*/

   modify ae;

      format Serious YN.

   ;

   run;

quit;

 

Note that the procedure is one that supports multiple run statements so needs a quit; to actually end;

zz
Calcite | Level 5 zz
Calcite | Level 5
Much appreciate it, ballardw!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3084 views
  • 0 likes
  • 2 in conversation