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

Hello,

After doing a lot of research, I would like a quick help please....

I am looking to optimise my table for reporting purposes (please see attachment). 
The aim is to lighten the table of duplicate data. 
I tried different solutions with data step, without success.
My problem can be fixed?

 

The table is the result of a succession of macros and it's difficult to solve it before the output. 
Modifications are easy in excel on a variable but when there are many of them, it's nicer to automate and it reduces the risk of error.

I appreciate your help and tips.

 

Mic

Capture d’écran 2019-04-24 à 00.05.57.jpg

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

How about adding a data step such as:

 

data want;
set have;
array _field name_variable RR;
do i = 1 to dim(_field);
    if _field{i} = lag(_field{i}) then _field{i} = " ";
    end;
drop i;
run;

(untested)

PG

View solution in original post

4 REPLIES 4
TomKari
Onyx | Level 15

Hi!

 

How are you creating that result, and what format is it in?

 

Is there a SAS dataset that we could work with, or do your macros write directly to a report. If there's a SAS dataset, what does it look like?

 

Can you describe the process of creating it in a bit more detail?

 

I can think of a couple of approaches, but more information is needed.

 

Tom

Mic35
Obsidian | Level 7

 

The SAS dataset is the same form as the one of the image (top). It’s the result of transpose and multiple merges.
The macro offers many possibilities (according to the settings) and requires an important data step at the end to show results...
It allows to obtain uni & bivariate results for continuous and categorical variables, to get RR/OR etc

 

i.e. %analysis(in=, out=, dep_var=, cont_vars=, class_vars=, silent=0, stddiff=2, RR=1, side=_vars_);

Mic

PGStats
Opal | Level 21

How about adding a data step such as:

 

data want;
set have;
array _field name_variable RR;
do i = 1 to dim(_field);
    if _field{i} = lag(_field{i}) then _field{i} = " ";
    end;
drop i;
run;

(untested)

PG
Mic35
Obsidian | Level 7

A big thank you to you PG.

Your code is very good.

With variables that appear in some cases and not in others (i.e. OR or RR), I added the code below to complete.
Now everything is perfect.
Thank you again.

 

 

ODS OUTPUT nLevels =work.nlevels;

PROC FREQ DATA= &out. NLEVELS ;
	TABLE _ALL_ / NOPRINT ;
RUN ;
PROC SQL NOPRINT ;
	SELECT STRIP(tableVar) INTO : listeDrop SEPARATED BY ","
	FROM  work.nlevesl
	WHERE NnonMissLevels = 0
	;
	ALTER TABLE  &out. DROP &listeDrop ;
QUIT ;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 944 views
  • 1 like
  • 3 in conversation