- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am trying to use the PUT function to convert a variable in z8 numeric format to a character format.
My code is as follows:
char_id = put(id,z8.);
where id is a numeric variable of format z8
However, when I run this the char_id variable is created, but is empty for every observations.
Thanks,
Mark
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't see any problem in the code or the result.
Here is my test:
589 data w1;
590 set tmp1.sample;
591 char_id = put(id,z8.);
592 put char_id=;
593 run;
char_id=00244302
char_id=01913948
char_id=01913956
char_id=01913964
char_id=01981501
char_id=02099179
char_id=02099187
char_id=02219492
char_id=02230694
char_id=02233014
char_id=02237317
char_id=02237319
char_id=02237320
char_id=02240835
char_id=02240836
char_id=02240837
char_id=02241751
char_id=02241927
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
can you post a sample of your data? plz
Just helps testing
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi novinosrin,
Thanks for your reply.
Here is a sample of the two variables in question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't see any problem in the code or the result.
Here is my test:
589 data w1;
590 set tmp1.sample;
591 char_id = put(id,z8.);
592 put char_id=;
593 run;
char_id=00244302
char_id=01913948
char_id=01913956
char_id=01913964
char_id=01981501
char_id=02099179
char_id=02099187
char_id=02219492
char_id=02230694
char_id=02233014
char_id=02237317
char_id=02237319
char_id=02237320
char_id=02240835
char_id=02240836
char_id=02240837
char_id=02241751
char_id=02241927
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help.
I tried pulling that section of code out into a separate data step and it seems to be working now. It still does not work when imbedded within another data step (as I was doing before). I suppose there is an underlying nuance of SAS that I do not quite grasp.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Should you further require any help at all, feel free to open a new thread or a follow up question, however you please.
Welcome to the SAS forum 🙂 Have fun!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Mogreenly wrote:
Thanks for your help.
I tried pulling that section of code out into a separate data step and it seems to be working now. It still does not work when imbedded within another data step (as I was doing before). I suppose there is an underlying nuance of SAS that I do not quite grasp.
This means that in your other code you do something that clears either id or your newly created character variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Maxim 2: read the log.
See my footnotes for hints on posting data.