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

I've seen this posted, but I've never seen a real answer - how do I convert a number to a character in SASVA?

 

I have a table where the data is loaded with a field as numeric but should really be character. This is a production table and the datatype cannot be changed at the source. It's also a very large table, so I don't want to have to create a staging table in order to do this (this is the only field that I need to change, I don't want to have to update a new table every time this report is ran). 

 

I cannot seem to make a calculated expression work that converts the number to a character. I've tried TreatAs() which didn't work (only treats a numeric as a different numeric type or datetype) and format() isn't recognizing any of the formats I give it (I don't think format converts types though).

 

What am I missing? Thnks!

1 ACCEPTED SOLUTION

Accepted Solutions
2 REPLIES 2
FredrikE
Rhodochrosite | Level 12

Try using Format:

 

VA_format.png

 

VivekRathod
Fluorite | Level 6

1. I had a data of 800gb, but the user has loaded it on lasr, and the column trdng_wk_end was having the values in number 20170112.

2. To create a date out of 20170112 kind of numbers follow the following.

2. create a new calculated item.  I used the combination of functions.

mdy - outer shell

parse - first inner shell

substr - second inner shell

format - inner most inner shell

 

My case:

DateFromMDY(Parse(Substring(Format('TRDNG_WK_END_DT'n, 'BEST2.'), 5, 2), 'COMMA2.'), Parse(Substring(Format('TRDNG_WK_END_DT'n, 'BEST2.'), 7, 2), 'COMMA2.'),

Parse(Substring(Format('TRDNG_WK_END_DT'n, 'BEST4.'), 1, 4), 'COMMA4.'))

 

Thanks

Madhusudhan

SAS Administrator 

Landmark Group

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 15660 views
  • 6 likes
  • 3 in conversation