Hi,
I am using below condition for extracting the age column. I am getting wrong output.
Could someone help me how to fix this:
1. output has age group and date which is wrong, it should have only age grouping.
2. how to remove trailing blanks in 999 value
trim(put(case
when yrdif(input(Dob ,yymmdd10.),input(Date ,yymmdd10.),'age') = . then 999
when yrdif(input(Dob ,yymmdd10.),input(Date ,yymmdd10.),'age') >= 0
then floor(yrdif(input(Dob ,yymmdd10.),input(Date ,yymmdd10.),'age'))
else 999
end,fmtageband.))
format csv file used:
current output :
Could someone help me with the current output : how to change 05-Sep to as 05-09 and ' 999' to 999(remove trailing blanks)
And, although we've talked about this millions of times here, never open a text file with Excel to inspect it. Open it with a text editor (even Windows Notepad will do, but it might choke on big files) instead. Notepad++ is the perfect choice for this.
Always (as in ALWAYS) post data as data steps with datalines, NEVER as pictures. NEVER.
Post text files as text in a window opened with this button:
and post the code you used to make SAS datasets out of them.
Also post the code you used to create the format, so we can recreate it, or advise on how to change it so it works.
You only show us a tiny portion of your code, we don't know what you did. Show us the data as SAS Data step code. Show us the entire program. If there are errors in the LOG, show us the ENTIRE log.
By the way, from an earlier post of yours, you KNOW that we want data presented as SAS data step code. We shouldn't have to constantly ask for data to be properly presented. From now on, please consider this mandatory, it should be done in every future post without us having to ask.
Hi,
I have used the provided expression in SAS DI studio to get the right values for Age column, but i am getting wrong output as
05-Sep instead of 05-09 and ' 999' trailing blanks instead of 999.
Any suggestion to modify the expression which i provided would be helpful in getting the right results.
Please provide the information requested.
Below expression is giving me trailing blanks when i have 999 values, could you please give me some suggestion/modification to avoid the trailing blanks for 999 values.
trim(put(case when yrdif(input(Dob ,yymmdd10.),input(Date ,yymmdd10.),'age') = . then 999 when yrdif(input(Dob ,yymmdd10.),input(Date ,yymmdd10.),'age') >= 0 then floor(yrdif(input(Dob ,yymmdd10.),input(Date ,yymmdd10.),'age')) else 999 end,fmtageband.))
@vnreddy wrote:
Below expression is giving me trailing blanks when i have 999 values, could you please give me some suggestion/modification to avoid the trailing blanks for 999 values.
trim(put(case when yrdif(input(Dob ,yymmdd10.),input(Date ,yymmdd10.),'age') = . then 999 when yrdif(input(Dob ,yymmdd10.),input(Date ,yymmdd10.),'age') >= 0 then floor(yrdif(input(Dob ,yymmdd10.),input(Date ,yymmdd10.),'age')) else 999 end,fmtageband.))
You already posted this, but we requested (MUCH!!!) more information. Reposting only this will not help in the least.
If you do not intend to assist us in helping you, then why are you here at all?
And, although we've talked about this millions of times here, never open a text file with Excel to inspect it. Open it with a text editor (even Windows Notepad will do, but it might choke on big files) instead. Notepad++ is the perfect choice for this.
What is that last photograph a picture of?
Did you accidentally let Excel open a CSV file and make its own guesses about what the strings in the text file might mean? That would explain why string likes '5-9' are being displayed as some type amorphous date that does not show the year value.
Personally, looks like EXCEL display and never trust Excel to not reformat values. Never. Especially if you paste some result into Excel.
Example: Open a new Excel worksheet, pick a cell, type 5-9. That is a five, a dash, and a 9. What does Excel display?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.