Azeem112
Azeem112

Reputation: 377

How to create a custom sas dataset

proc sql;
 select *
 INTO: SAGIA
 From Sasoprsk.Cust_field_value, Sasoprsk.Cust_obj_7
 Where Cust_field_value.BUSINESS_OBJECT_RK eq Cust_obj_7.CUST_OBJ_7_ID;
run;

data Work.Temp = &SAGIA;
run;

I want to create a custom dataset where BUSINESS_OBJECT_RK column values are equal to CUST_OBJ_7_ID but one is of string type and one is of numeric type. so its not working and then i want to create a dataset in work library of my selected fields as i wrote code above but it didn't work.

proc print data=&SAGIA is working fine but data statement is giving me a syntax error that something is missing.

data Work.Temp = &SAGIA._ALL_; didn't work

data Work.Temp = &SAGIA _null_; didn't work

Upvotes: 1

Views: 746

Answers (1)

G.Arima
G.Arima

Reputation: 1171

Why don't you create the table directly rather than creating the macro and storing it into dataset?

data abc;
input a $1. b;
cards;
1 20
2 30
3 40
;
run;

data pqr;
input p q;
cards;
1 1000
3 7000
;
run;

1) Using proc sql

proc sql;
create table sagia as
 select *
 From abc, pqr
 Where input(abc.a,1.) eq pqr.p;
run;

2) Using merge

data abc;
set abc;
p = a*1;  /* converts character column a into numeric column p */
/*or p=input(a,1.);*/
drop a;
run;

proc sort data=abc;
by p;
run;

proc sort data=pqr;
by p;
run;

data sagia;
merge abc(in=table1) pqr(in=table2);
by p;
if table1 and table2;
run;

Let me know if anything else was required.

Upvotes: 1

Related Questions