Help using Base SAS procedures

Put Aterisk (*) in front of column values

Reply
Contributor
Posts: 33

Put Aterisk (*) in front of column values

Hi,

I have a dataset lke this:

Company Name                      Sample

A                                              15

B                                               25

C                                               14

D                                               30

E                                               28

I want to put aterisk (*) in front of the company name with sample less than 25.

My final dataset would look like:

Company Name                      Sample

*A                                              15

B                                               25

*C                                               14

D                                               30

E                                               28

I would appreciate your time suggestions reagrading the same.

Thanks a lot

SAS Super FREQ
Posts: 8,744

Re: Put Aterisk (*) in front of column values

Hi:

  Do you really want a final dataset or do you want a report? This is fairly simple to accomplish in a DATA step program with a statement something like (untested code):

data new;

  length company $20;  /* make company variable large enough to include the * (asterisk) */

  set original;

  if sample lt 25 then company=catt('*',company);

run;

  However, if what you want is a final report (such as an HTML, RTF or PDF file), then you could use PROC REPORT to change the color of the entire ROW with SAMPLE lt 25 to some color like yellow....in which case, an asterisk might not be needed. But of course, you can't change the color of a row in a dataset -- only in a report that goes to a destination which supports style changes.

cynthia

Super Contributor
Posts: 1,636

Re: Put Aterisk (*) in front of column values

data have;

length company $ 12;

input company $ sample;

company=ifc(sample<25,catt('*',company),company);

cards;

A                                              15

B                                               25

C                                               14

D                                               30

E                                               28

;

proc print;run;

Linlin

Super Contributor
Posts: 276

Put Aterisk (*) in front of column values

data have;

length company $ 12;

input company $ sample;

cards;

A                                              15

B                                               25

C                                               14

D                                               30

E                                               28

;

run;


data have1;

set have;

if sample lt 25 then company="*"||strip(company);

else company=company;

run;

Sanjeev.K

Ask a Question
Discussion stats
  • 3 replies
  • 127 views
  • 0 likes
  • 4 in conversation