BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello I need to obtain a single sas file which has all the periods Period 1 and Period2 ( period 2A + Period2B ).

Period 1 Period 2A Period 2B
Variable COLUMNS COLUMNS COLUMNS
Transaction ID 1 – 8 1 – 8 1 – 8
Date of Sale 9 – 18 9 – 18
Time of Sale 19 – 26 9 – 16
Laptop Model 27 – 32 19 – 24
Units Sold 33 – 35 25 – 27
Warranty 36 28

I've used the code -

libname sc 'c:\Sas';
data period1;
infile 'c:\Sas\period1_sales_data.dat.';
Input TransactionID $1-8
DateofSale $9-18
TimeofSale $19-26
LaptopModel $27-32
UnitsSold 33-35
Warranty 36 ;
proc print data = period1;
TITLE 'period1 sales';
run;


data period2A;
infile 'c:\Sas\period2_sales_data_A.dat.';
Input TransactionID $1-8
DateofSale $9-18
LapstopModel $19-24
UnitsSold 25-27
Warranty 28 ;
proc print data=period2A;
TITLE 'period2A sales';
run;


data period2B;
infile 'c:\Sas\period2_sales_data_B.dat';
Input TransactionID $1-8

TimeofSale $9-16;
Proc sort data = period2_sales_data_B;
By TransactionID;
proc print data=period2B;
TITLE 'period2B sales';
RUN;


Using the above code craetes two columns of the Laptop model , when one column ends at some point the data remaining is printed on the second column. I think that i need to change the oredr of the input variables in data setp.

Kindly guide,
markc
2 REPLIES 2
RickM
Fluorite | Level 6
Your code does nothing but read in data and print it (it also looks like that proc sort would fail). There is no creation of a file that holds both periods.

You need to take an hour or two and study the set and merge statements and see what each does. If you did that then you wouldn't have nearly half as many questions as you do.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The previous suggestions from your posts to read about SET/MERGE by BY as well as taking consideration with using SAS numeric variables for DATE and TIME type references has either been ignored or forgotten.

Individuals on these forums take the time to address the requests for help/guidance, only to find that a subsequent post continues with disregard to others' feedback.

Furthermore, as has been suggested, investing in time for self-checking of your program and the logs will go far to help one absorb useful habits when dealing with SAS program development and debugging.

So, given the latest post and your point about multiple variables representing laptops, as I see it you have two SAS variables, one named LapstopModel and another called LaptopModel -- maybe intentional but who knows. Also, your question is input data related and so you will be best suited to answer it, I believe, unless you are willing to generate SAS log diagnostics using commands, such as:

LIST;

putlog _infile_;

putlog _all_;

Again, to share only a non-working SAS program (as mentioned with the PROC SORT specification error), is not going to get you very far, in my experience. In the future, share all of your SAS code but do so with a captured/pasted SAS log output with it.

Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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