- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 |
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
id_f_f = catx("-",put(id_f,z4.),put(f,z3.));
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
id_f_f = catx("-",put(id_f,z4.),put(f,z3.));
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you !
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.