Hi,
I am facing problem after importing data in excel format.
Below is my procedure to access the saved data in order to start work on my dataset:
Each time I log in to my SAS Studio, I need to click on Servers Files and Folders and click on the saved data either in .xlsx or .sas format to run it. As refer to the attachment label as 1, the output file I have run as work.cervicalcancer.
However, when I click on the Library -> Work -> cervicalcancer to run it, the Proc Datasets and Proc Prints statements show only work.query and work.details respectively (as shown as the picture below).
Thus, why it has different work file name appear instead only work.cervicalcancer?
Thank you for your reply.
I don't know what your question is. If you want to save the file permanently after importing it, save it to a library.
libname myFiles '/folders/myfolders/';
data myFiles.CervicalCancer;
set CervicalCancer;
run;
This copies the file to the location above. So the next time you want to use the dataset you assign the libname and you have the file available.
Please post your code as text. I can't read the image and it doesn't scale.
You have no comments in your code, comment each procedure with what you think/expect it to be doing.
Comments really really really help here.
%*Creates a table called QUERY with the data from Cervical Cancer. There's no WHERE clause so there's no filter on the number of rows but perhaps it's selecting less columns than the main data set. If not, it's not actually doing anything here besides creating a duplicate dataset.
PROC SQL;
CREATE TABLE WORK.query AS
SELECT Age , Number_of_sexual_partners , 'First_sexual_intercourse_(age)'n , Number_of_pregnancies , Smokes , 'Smokes_(years)'n , 'Smokes_(packs/year)'n , Hormonal_Contraceptives , 'Hormonal_Contraceptives_(years)'n , IUD , 'IUD_(years)'n , STDs , 'STDs_(how_many?)'n , 'STDs:condylomatosis'n , 'STDs:cervical_condylomatosis'n , 'STDs:vaginal_condylomatosis'n , 'STDs:vulvo-perineal_condylomatos'n , 'STDs:syphilis'n , 'STDsSmiley Tongueelvic_inflammatory_disease'n , 'STDs:genital_herpes'n , 'STDs:molluscum_contagiosum'n , 'STDs:AIDS'n , 'STDs:HIV'n , 'STDs:Hepatitis_B'n , 'STDs:HPV'n , 'STDs: Number_of_diagnosis'n , 'STDs:Year_since_first_diagnosis'n , 'STDs:Year_since_last_diagnosis'n , 'Previous_Dx:Cancer'n , 'Previous_Dx:CIN'n FROM WORK.CERVICALCANCER;
RUN;
QUIT;
%*Run a contents on the QUERY dataset from previous step to see field types and formats. The field names are stored in a dataset called Details;
PROC DATASETS NOLIST NODETAILS;
CONTENTS DATA=WORK.query OUT=WORK.details;
RUN;
%*Displays the output from proc datasets - which is the details dataset.;
PROC PRINT DATA=WORK.details;
RUN;
1. OUT= in a SAS procedure means a data set will be created. What exactly is in that data set depends on the PROC. Note that this is for SAS PROCEDURES, not a Data Step. For PROC DATASETS you can see the OUT=option on the CONTENTS statement.
Digging through the documetentation a bit, yields the following:
In general, the OUT will be noted in the documentation and there will be information on what's in the dataset.
2. I don't know what you're asking here or what you're expecting. It's not clear at all.
Read the comments again.
Identify the input data sets for each step and the output data sets.
Details is a new dataset that has very different content than Cervical Cancer - it has data about the cervical cancer dataset. Open it.
Query is from the SQL procedure. You ran it, so why did you do that? It creates a new table name because the table isn't usually identical to the source as it is in this case. You can easily add new variables or create summary statistics in the procedure so it creates a new table name. You have control over the output name and since it's Query, my guess is you didn't change the name.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.