BookmarkSubscribeRSS Feed
Samsung
Calcite | Level 5

I would like to read data as shown in the excel file and display the same as output, what is the easiest way to do that.

 

For example,

 

data have;

infile datalines dlm="#";

input Disease $ Description $;

datalines;

Atrial Flutter # Atrial flutter (AFL) is a common abnormal heart rhythm that starts in the atrial chambers of the heart. When it first occurs, it is usually associated with a fast heart rate and is classified as a type of supraventricular tachycardia.

Tachycardia # Tachycardia is a condition that makes your heart beat more than 100 times per minute. There are three types of it: Supraventricular. This happens when the electrical signals in the organ's upper chambers misfire and cause the heart rate to speed up. It beats so fast that it can't fill with blood before it contracts.

;

run;

 

 

Main issue is with the text wrapping since it reads as one long line of text which I want it to be spread across multiple lines just as in excel file.

The output of sas dataset should like the one attached in excel file (The text should wrap just as in the excel file )

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20
> display the same as output, what is the easiest way to do that
How is the data displayed? In a report? Created how?

Also many people will *not* download potentially noxious excel files.
Shmuel
Garnet | Level 18

Let suppose that description is up to 130 characters long and you want to print a column of 30 characters each

without breaking a word:

data want;
        length description $130  column $30;
  set have;
        flag=1;
       do until flag=0;
            column = substr(description,1,30);
            pos = index(column, ' ', -1);    /* last space in column */
            if column ne ' ' and pos ne 0 then
               do; column = substr(column,1,pos-1);
                     description = substr(description,pos+1); /* rest of description */
                     output;
              end;
           if description = ' ' then flag=0;  /* no more text to subtract */
      end;
      drop description;
run;

code was not tested. use it as a base to split the description.

 

Tom
Super User Tom
Super User

PROC REPORT will flow the long values for you.

proc report data=have nofs headline;
  column disease description;
  define disease / order ;
  define description / display flow width=50;
run;
SAS 9.4 on WINDOWS                                                      08:30 Friday, December 27, 2019   1

  Disease                    Description
  -----------------------------------------------------------------------------
  Atrial Flutter             Atrial flutter (AFL) is a common abnormal heart
                             rhythm that starts in the atrial chambers of the
                             heart. When it first occurs, it is usually
                             associated with a fast heart rate and is
                             classified as a type of supraventricular
                             tachycardia.
  Tachycardia                Tachycardia is a condition that makes your heart
                             beat more than 100 times per minute. There are
                             three types of it: Supraventricular. This happens
                             when the electrical signals in the organ's upper
                             chambers misfire and cause the heart rate to
                             speed up. It beats so fast that it can't fill
                             with blood before it contracts.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

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
  • 3 replies
  • 737 views
  • 0 likes
  • 4 in conversation