BookmarkSubscribeRSS Feed
Rohit12
Obsidian | Level 7

Hello 

 

I have below dataset 

 

data new;

input room $ equpi $10.;

datalines;

A printer

A fax

A monitor

B fax

B monitor

C LCD

D montior

;

run;

 

Below is the output I want 

 

 
6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

Can you post the picture of your desired output in a different format? For some reason it is not showing.

Rohit12
Obsidian | Level 7

Room

printer

Fax

Monitor

LCD

A

TRUE

TRUE

TRUE

FALSE

B

FALSE

TRUE

TRUE

FALSE

C

FALSE

FALSE

FALSE

TRUE

D

FALSE

FALSE

TRUE

FALSE

 

 

Is it showing now ?

Kurt_Bremser
Super User
data new;
input room $ equpi $10.;
datalines;
A printer
A fax
A monitor
B fax
B monitor
C LCD
D monitor
;
run;

proc transpose data=new out=want (drop=_name_);
by room;
id equpi;
var equpi;
run;

data want;
set want;
array chars {*} _character_;
do i = 2 to dim(chars);
  if missing(chars{i})
  then chars{i} = 'FALSE';
  else chars{i} = 'TRUE';
end;
drop i;
run;
data_null__
Jade | Level 19
data new;
input room $ equpi :$10.;
datalines;
A printer
A fax
A monitor
B fax
B monitor
C LCD
D monitor
;
run;
proc summary data=new nway completetypes;
   class room;
   class equpi / order=data;
   output out=full(drop=_type_);
   run;
proc transpose data=full out=wide(drop=_name_);
   by room;
   var _freq_;
   id equpi;
   run;
proc print;
   run;

Capture.PNG 

Rohit12
Obsidian | Level 7

I have attached the output in Xls Sheet that i have attached 

rogerjdeangelis
Barite | Level 11
I assume you want numeric 0/1(bolean logicals) displayed
as numeric(bolean logicals) FALSE/TRUE  and
not the character strings FALSE/TRUE.

Somewhere buried in excel is an option to display 0/1 as logical True/False.

data have;
input room $ equpi :$10.;
datalines;
A printer
A fax
A monitor
B fax
B monitor
C LCD
D monitor
;
run;

libname xel "d:/xls/truefalse.xlsx";
Ods Exclude All;
Ods Output Observed=xel.want(Rename=Label=Gov);
Proc Corresp Data=have Observed dim=1;
   Table room, equpi;
Run;
Ods Select All;
libname xel clear;

SOAPBOX ON
Once upon a time  tools/options/formula evaluation?, provided a TRUE/FALSE(logical)  format.
Excel like SAS does not honor legacy fnctionality, a command line would force SAS
to honor legacy scripting at least.
Bur a command line is only for programmers?
SOAPBOX OFF

proc print data=want;run;


 Obs    GOV    LCD    FAX    MONITOR    PRINTER    SUM

  1     A       0      1        1          1        3
  2     B       0      1        1          0        2
  3     C       1      0        0          0        1
  4     D       0      0        1          0        1
  5     Sum     1      2        3          1        7

You can use a formula in excel to get TRUE/FALSE text

=IF(RC[1]=1,"TRUE",IF(RC1=0,"FALSE","NULL"))

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1458 views
  • 3 likes
  • 5 in conversation