BookmarkSubscribeRSS Feed
Nupur20
Calcite | Level 5

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

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

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

Linlin
Lapis Lazuli | Level 10

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

kuridisanjeev
Quartz | Level 8

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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