I have a c# app that has a notes section that allows the users to put some text in there and save it. My issue is that after it is saved and I want to re-display it the carriage return is removed and all the space is removed and everything is stuck together. What is the best way to handle this?
I have a similar situation creating .sas files and adding carriage returns.
Any help would be appreciated.
Thank you
If you submitted a program like that in a SAS program then the line break would be eliminated.
data _null_;
notes='12345
6789';
put notes= / notes= $hex24. ;
run;
notes=123456789
notes=313233343536373839
But if you put in the hexcodes using literals they will make it in.
data _null_;
notes='12345' || '0d0a'x || '6789';
put notes= / notes= $hex24. ;
run;
notes=12345
6789
notes=31323334350D0A36373839
So in whatever C logic you have to generate the string generate it like the example above instead.
...
set notes='This is a testTHIS IS A TESTtest2TEST3TEST4TEST5TEST6'
|| '0D0A'x
|| 'TEST7'
...
This is a pure C# question, right? So this might not be the best place to ask for help.
This sounds like a .Net property in your Textbox Control. Which user control do you use? Do you use WinForms or WPF?
Look for some properties like "Mulitline" at your control (e.g. TextBox.Multiline Property (System.Windows.Forms))
Andreas,
Within my C# app it displays correctly when typed in. When I send the insert or update sql to sas and then I go back to view the text it's one line with the spaces removed. If I'm saving the text in sas do I have put the carriage returns in when I do the insert or update?
Thank you for your help
How are you verifying the carriage return is removed? If you're opening a dataset up in sas (.sas7bdat), it won't display multiline character fields even if they have CRs in them - it will just eat up the space and display as if that character didn't exist. You'd have to look at the hex value of the sting to see if '0D' was in there somewhere.
If that's not the issue (and it doesn't sound like it's the entire issue), then I agree it's probably a C#/.NET issue.
Hi Snoopy,
Thank you for the reply. I see that it is removed when I go into my C# app and open up the form that displays the text. When I initially entered it, it displayed correctly. When I saved and closed the app and then opened it up the carriage returns I added were removed and the text is all together.
Thank you
How is this related to SAS?
Is your application storaging text into variables in a SAS dataset?
What actual SAS code are you using to move the data into and out of SAS?
Hi Tom,
I'm inserting this text into a variable in a sas dataset. Here is some example code.
proc sql undo_policy = none ;
update tblNotes (cntllev=rec)
set notes='This is a testTHIS IS A TESTtest2TEST3TEST4TEST5TEST6
TEST7'
where id = 9999;
quit ;
Based on Snoopys suggestion I was able to view the hex after I enter the carriage returns in my multiline textbox. It shows \r\n where my carriage returns are. I'm losing them some how on the way to sas.
Thank you
If you submitted a program like that in a SAS program then the line break would be eliminated.
data _null_;
notes='12345
6789';
put notes= / notes= $hex24. ;
run;
notes=123456789
notes=313233343536373839
But if you put in the hexcodes using literals they will make it in.
data _null_;
notes='12345' || '0d0a'x || '6789';
put notes= / notes= $hex24. ;
run;
notes=12345
6789
notes=31323334350D0A36373839
So in whatever C logic you have to generate the string generate it like the example above instead.
...
set notes='This is a testTHIS IS A TESTtest2TEST3TEST4TEST5TEST6'
|| '0D0A'x
|| 'TEST7'
...
Hi Tom,
Thank you for the information. I'm working on it now and will post my results when I finish.
Thank you
Hi Tom,
Thank you that fixed it.
Thanks again to everyone for their help
Hi Tom,
Sorry to bother you but how would I handle this with an insert statement? When I try this I get an error for the "||".
proc sql undo_policy = none ;
Insert into tblnotes (cntllev=rec, id, notes)
values(999, 'THIS' || '0d0a'x || 'IS' || '0d0a'x || 'A' || '0d0a'x || 'TEST' || '0d0a'x || 'OF THIS CODE ' || '0d0a'x || 'TESTING')
;
quit ;
Thanks for the help
That type of transactional processing is not something I normally attempt to do with SAS. Why not just insert a blank value and then use the update syntax to put the value into the NOTE variable? Or you could also just have C write the whole string as hex digits?
values(999,'544849530D0A49530D0A410D0A544553540D0A4F46205448495320434F44452020200D0A54455354494E47'x)
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!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.