BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASdevAnneMarie
Barite | Level 11

Hello Experts,

 

I have a data ID_F and F (in numeric format), I would like to put the ID_F in format 0000 and F in 000 format.

Do you know how to do it easily beacause I apply Repet function with IF THEN ELSE condition. Maybe there is some format statement ? I joined the data. Thank you for your help !

 

ID_F (numeric) F (numeric) ID_F-F (character)
73 1 0073-001
83 2 0083-002
45 4 0045-004
1 23 0001-023
453 23 0453-023
1 ACCEPTED SOLUTION
5 REPLIES 5
SASdevAnneMarie
Barite | Level 11
Thank you, Kurt!
Kurt_Bremser
Super User

For the future: do not bother to attach Excel files.

Many of us won't (or even can't, for security reasons) download Office files.

Excel spreadsheets do not have the concept of fixed  column attributes.

I would have needed to

  • download the file
  • upload it to my ODA account
  • run PROC IMPORT, with no guarantee that the resulting dataset looks like yours

For simple issues (like this here), the values and description are sufficient. For more complex issues, post DATA step code (with DATALINES), so we can exactly recreate your dataset with simple copy/paste and submit. It's less work for you and for us.

SASdevAnneMarie
Barite | Level 11
OK Kurt,
Thank you !
ballardw
Super User

Suggestion: your subject line should read something like "create character variable from numeric  values".

 

Please avoid the use of the word "Format" unless you mean a SAS Format. Format has very specific meaning in SAS related to display of values. Run Proc Contents on any of your data sets and you will see the Format is property of variables.

 

For instance the Format to display a numeric value with a fixed number of characters and leading zeroes is the Zw.d format where W is the number of characters and D is the number of decimal positions to show.

A format of Z4. will display an integer value with 4 characters padding leading zeroes as needed.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 1010 views
  • 1 like
  • 3 in conversation