Sei sulla pagina 1di 4

===============day 5=====================================

to group by supplier id and category id in one combination each


===============================================================
data product_new;
set work.product_new;
run;
proc sort data=imart2.product_new out=product_new noduprec;
By supplierid categoryid;
run;
data product_new;
set product_new2;
By supplierid categoryid;
run;
proc sql ;
create table temp as select supplierid , categoryid , sum (UnitsInStock) as tota
l_stock
from imart2.product_new
group by supplierid,categoryid;
quit;

==============================================================
Append==============
proc append base=orders2012 data=orders2011 (rename=(order_id=order_no))force;
run;
force used for append forcefully when variable names are not match
============================================================
proc append base=orders2012 data=orders2011 (rename=(order_id=order_no))force;
where ship_via= 'Speedy Express' ;
run;
========================================================================
data orderall;
set orders2012 orders2010 orders2011;
run;
proc sort data = orders2010; by order_id; run;
proc sort data = orders2011; by order_id; run;
proc sort data = orders2012; by order_id; run;

data orderall;
set orders2012 (rename=(order_no=order_id)) orders2010 orders2011;
by order_id;
run;
data orderall;
set orders2010;
set orders2011;
run;
================================================================
Day 6 Call History Problem ========================================
========================================================================
data ch;
Infile 'C:\Documents and Settings\BAP\Desktop\I-Mart Project\Day-5\call history.
txt';
input junk $200.;
informat junk $200.;
Run;

Data

Testdata;

Length SR_Num $ 2 Date $ 10 Time $ 10 Id $ 20 Phone_num $ 20 Duration 3 Amount $


3 Pos1 3 Pos2 3;
Infile 'C:\Documents and Settings\BAP\Desktop\I-Mart Project\Day-5\call history.
txt';
Input

Amount $ Duration Id $ Phone_num $ Sr_Num $ Date $ Time $;

Sr_Num = Scan(_Infile_,1,' ');


Date
= Scan(_Infile_,2,' ');
Time
= Scan(_Infile_,3,' ');
Amount = Scan(_Infile_,-1,' ');
Duration = Scan(_Infile_,-2,' ')/60;
Phone_Num= Scan(_Infile_,-3,' ');
Pos1 = Find(_Infile_,Trim(time))+Length(Trim(time))+1;
Pos2 = Find(_Infile_,Trim(Phone_Num))-1;
Id = Substr(_Infile_,Pos1,Pos2-Pos1);
Drop Pos1 Pos2;
Run;
Proc Print Data= Testdata;
Run;
data testdata2;
set testdata;
Format num_date mmddyy10. num_time time.;
num_date = Input(date,ddmmyy10.);
num_time = Input(time,time.);
num_amount = Input(amount,best12.);
Char_duration=Put(duration,$3.);

run;
Proc Print Data= Testdata2;
Run;

data ch;
Infile 'C:\Documents and Settings\BAP\Desktop\I-Mart Project\Day-5\call history.
txt';
input junk $200.;
informat junk $200.;
Run;
Data Testdata;
Length SR_Num $ 2 Date $ 10 Time $ 10 Id $ 20 Phone_num $ 20 Duration 3 Amount $
3 Pos1 3 Pos2 3;
Infile 'C:\Documents and Settings\BAP\Desktop\I-Mart Project\Day-5\call history.
txt';
Input Amount $ Duration Id $ Phone_num $ Sr_Num $ Date $ Time $;
Sr_Num = Scan(_Infile_,1,' ');
Date
= Scan(_Infile_,2,' ');
Time
= Scan(_Infile_,3,' ');
Amount = Scan(_Infile_,-1,' ');
Duration = Scan(_Infile_,-2,' ')/60;
Phone_Num= Scan(_Infile_,-3,' ');
Pos1 = Find(_Infile_,Trim(time))+Length(Trim(time))+1;
Pos2 = Find(_Infile_,Trim(Phone_Num))-1;
Id = Substr(_Infile_,Pos1,Pos2-Pos1);
Drop Pos1 Pos2;
Run;
Proc Print Data= Testdata;
Run;
data testdata2;
set testdata;
Format num_date mmddyy10. num_time time.;
num_date = Input(date,ddmmyy10.);
num_time = Input(time,time.);
num_amount = Input(amount,best12.);
Char_duration=Put(duration,$3.);
run;
Proc Print Data= Testdata2;
Run;
data s;
weeks=intck ('week','31dec2000'd,'01jan2012'd);
run;
proc print;

run;
data b;
TargetYear= intnx('year','28feb92'd,10);
run;
proc print;
format Targetyear mmddyy10.;
run;
-Thanks & Regards,
SATISH MISTRY 9821569263

Potrebbero piacerti anche