Help using Base SAS procedures

SAS Code

Reply
N/A
Posts: 0

SAS Code

Hello ,

When i run the code below i get message that the WORK.PERIOD2A.DATA does not exist . could you suggest please what mistake i'm doing.


libname example 'c:\SAS' ;
data sc.period2A;
infile 'c:\Cwa\period2_sales_data_A.dat';
Input TransactionID $1-8
DateofSale $9-18
LaptopModel $19-24
UnitsSold 25-27
Warranty 28;
Proc Sort Data = period2A;
By TransactionID;
proc print data=period2A;
run;


I want to save the sorted dataset in the C file.

kind regards ,

siddharth
Super Contributor
Posts: 359

Re: SAS Code

You create sc.period2A but I do not see where you create period2A.
So it does not exist.
Do you have a library sc defined, it is not in this code.

Also put in some run; statements and you will have better luck reading your log.
N/A
Posts: 0

Re: SAS Code

Hello ,

thank you for the suggestion. I changed the code as :

libname sc 'c:\Cwa';
data period1;
infile 'c:\Cwa\period1_sales_data.dat';
Input TransactionID $1-8
DateofSale $9-18
TimeofSale $19-26
LaptopModel $27-32
UnitsSold 33-35
Warranty 36;
proc sort data = period1;
By DateofSale;
proc print data = period1;
title 'period 1 Sales ';
RUN;

I get the sorted output in the output window when i use above code then i add sc in the data line and then rerun the code to save the permannent file of sorted ( by date of sale ) file. but when i open the file i dont get the data in sorted format .

Kindly guide.

regrards ,

markc
Super Contributor
Posts: 359

Re: SAS Code

You need to output the sorted data to the permanent lib.


proc sort data = period1 out = sc.period1;
By DateofSale;
RUN;
N/A
Posts: 0

Re: SAS Code

Hello ,

I used the code

libname sc'c:\Cwa';
data period2A;
infile 'c:\Cwa\period2_sales_data_A.dat';
Input TransactionID $1-8
DateofSale $9-18
LaptopModel $19-24
UnitsSold 25-27
Warranty 28;
proc sort data = period2Aout = sc.period2A;
By DateofSale;
RUN;
proc print data = period2A;
title 'period 2A Sales ';
RUN;

but it didnt work .Do i need to change the format of date in the input

.The date is in format :17/11/2009
Any chage would you recommend in the date format to use proc sort .I used date as a character $ variable .


kind reagards ,

mark
Regular Contributor
Posts: 165

Re: SAS Code

Rather than just saying "it didn't work" you should include the relevant portion of the SAS log.

if that is the exact code used then you need a space between period2A and out= in:

proc sort data = period2Aout = sc.period2A;

This would likely cause SAS to not even run the proc sort.
Ask a Question
Discussion stats
  • 5 replies
  • 147 views
  • 0 likes
  • 3 in conversation