DATA Step, Macro, Functions and more

Apply format to a variable in sas

Accepted Solution Solved
Reply
Contributor zz
Contributor
Posts: 28
Accepted Solution

Apply format to a variable in sas

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


Accepted Solutions
Solution
‎10-25-2016 11:58 AM
Super User
Posts: 10,516

Re: Apply format to a variable in sas

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


All Replies
Contributor zz
Contributor
Posts: 28

Re: Apply format to a variable in sas

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!

Solution
‎10-25-2016 11:58 AM
Super User
Posts: 10,516

Re: Apply format to a variable in sas

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;

Contributor zz
Contributor
Posts: 28

Re: Apply format to a variable in sas

Much appreciate it, ballardw!
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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