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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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'

...

View solution in original post

11 REPLIES 11
AndreasMenrath
Pyrite | Level 9

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))

jerry898969
Pyrite | Level 9

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

snoopy369
Barite | Level 11

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.

jerry898969
Pyrite | Level 9

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

Tom
Super User Tom
Super User

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?

jerry898969
Pyrite | Level 9

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

Tom
Super User Tom
Super User

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'

...

jerry898969
Pyrite | Level 9

Hi Tom,


Thank you for the information.  I'm working on it now and will post my results when I finish.

Thank you

jerry898969
Pyrite | Level 9

Hi Tom,

Thank you that fixed it.

Thanks again to everyone for their help

jerry898969
Pyrite | Level 9

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

Tom
Super User Tom
Super User

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)

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 1508 views
  • 6 likes
  • 4 in conversation