Hello, I'm new and I keep getting errors when I try to create a CSV:
ODS CSV FILE=‘/home/u59281773/sasuser.v94/BALL1986.csv’;
PROC PRINT DATA=BASEBALL86;
RUN;
ODS CSV CLOSE;
or exclude missings from a boxplot:
PROC SGPLOT DATA = BIRTH2001 nomiss;
VBOX tounces / GROUP = SMOKE;
TITLE 'Birthweights by Smoking Status';
RUN;
Putting NOMISS in the initial PROC SGPLOT is how I think I've seen others do it, but all it does is cause a syntax error and make my graph disappear!
Can anyone advise? Thanks!
Full code:
%web_drop_table(BIRTH);
FILENAME REFFILE '/home/u59281773/sasuser.v94/LIB/nc_birth.xlsx';
PROC FORMAT;
VALUE RACE /*labels the possible values of the variables*/
0='other non-White' 1='White' 2='Black' 3='American Indian'
4='Chinese' 5='Japanese' 6='Hawaiian' 7='Filipino'
8='Other Asian or Pacific Islander';
VALUE SMOKESTAT
0 = 'No'
1 = 'Yes' ;
RUN;
PROC IMPORT DATAFILE=REFFILE
DBMS=XLSX
OUT=BIRTH;
GETNAMES=YES;
SHEET='Sheet1'; /*selecting which sheet within the file to use*/
RUN;
PROC CONTENTS DATA=BIRTH; RUN;
%web_open_table(BIRTH);
data BIRTH2001;
set BIRTH;
LABEL
RACEMOM = 'Race of Mother'
SMOKE = 'Did mother smoke during pregnancy?';
/*attempt to label the variables*/
FORMAT RACEMOM RACE. SMOKE SMOKESTAT.;
run;
*Creating the histograms;
PROC SGPLOT DATA = BIRTH2001;
HISTOGRAM tgrams;
TITLE 'Birthweights in Ounces';
RUN;
PROC SGPLOT DATA = BIRTH2001;
HISTOGRAM tounces;
TITLE 'Birthweights in Grams';
RUN;
PROC SGPLOT DATA = BIRTH2001 nomiss;
VBOX tounces / GROUP = SMOKE;
TITLE 'Birthweights by Smoking Status';
RUN;
*how to exclude missings?;
PROC SGPLOT DATA = BIRTH2001;
REG x=gained y=tgrams;
TITLE 'Birthweights by Weight Gain During Pregnancy';
RUN;
DATA BASEBALL86;
SET sashelp.BASEBALL;
TITLE 'Baseball 86 Stats';
RUN;
*create temporary dataset with preset data;
*Creating Excel file and replacing previous temp file;
PROC EXPORT DATA=BASEBALL86
OUTFILE = '/home/u59281773/sasuser.v94/Baseball86.xlsx'
DBMS = xlsx
REPLACE;
RUN;
ODS CSV FILE=‘/home/u59281773/sasuser.v94/BALL1986.csv’;
PROC PRINT DATA=BASEBALL86;
RUN;
ODS CSV CLOSE;
In the future, please include the errors that you're receiving or indicate what is happening. We cannot run your code as we don't have the source files.
For your first issue, I think you have pretty quotes around your path, it needs to be a single or double quote not the curly ones. Office applications have a tendency to add those - did you copy/paste your code from somewhere. Basically, replace your quotes around the path for the CSV file and I think it'll be fine.
Notice how the editor doesn't color it the same way it colours other quoted text, highlighting that it's different.
Regarding filtering out observations - there is no NOMISS option on SGPLOT perhaps that is in another procs you've seen? You can filter out data using a WHERE statement but it depends exactly on what you're trying to filter out. Typically missing data is filtered out by default.
@akimme wrote:
Hello, I'm new and I keep getting errors when I try to create a CSV:
ODS CSV FILE=‘/home/u59281773/sasuser.v94/BALL1986.csv’; PROC PRINT DATA=BASEBALL86; RUN; ODS CSV CLOSE;
or exclude missings from a boxplot:
PROC SGPLOT DATA = BIRTH2001 nomiss; VBOX tounces / GROUP = SMOKE; TITLE 'Birthweights by Smoking Status'; RUN;
Putting NOMISS in the initial PROC SGPLOT is how I think I've seen others do it, but all it does is cause a syntax error and make my graph disappear!
Can anyone advise? Thanks!
Full code:
Spoiler%web_drop_table(BIRTH); FILENAME REFFILE '/home/u59281773/sasuser.v94/LIB/nc_birth.xlsx'; PROC FORMAT; VALUE RACE /*labels the possible values of the variables*/ 0='other non-White' 1='White' 2='Black' 3='American Indian' 4='Chinese' 5='Japanese' 6='Hawaiian' 7='Filipino' 8='Other Asian or Pacific Islander'; VALUE SMOKESTAT 0 = 'No' 1 = 'Yes' ; RUN; PROC IMPORT DATAFILE=REFFILE DBMS=XLSX OUT=BIRTH; GETNAMES=YES; SHEET='Sheet1'; /*selecting which sheet within the file to use*/ RUN; PROC CONTENTS DATA=BIRTH; RUN; %web_open_table(BIRTH); data BIRTH2001; set BIRTH; LABEL RACEMOM = 'Race of Mother' SMOKE = 'Did mother smoke during pregnancy?'; /*attempt to label the variables*/ FORMAT RACEMOM RACE. SMOKE SMOKESTAT.; run; *Creating the histograms; PROC SGPLOT DATA = BIRTH2001; HISTOGRAM tgrams; TITLE 'Birthweights in Ounces'; RUN; PROC SGPLOT DATA = BIRTH2001; HISTOGRAM tounces; TITLE 'Birthweights in Grams'; RUN; PROC SGPLOT DATA = BIRTH2001 nomiss; VBOX tounces / GROUP = SMOKE; TITLE 'Birthweights by Smoking Status'; RUN; *how to exclude missings?; PROC SGPLOT DATA = BIRTH2001; REG x=gained y=tgrams; TITLE 'Birthweights by Weight Gain During Pregnancy'; RUN; DATA BASEBALL86; SET sashelp.BASEBALL; TITLE 'Baseball 86 Stats'; RUN; *create temporary dataset with preset data; *Creating Excel file and replacing previous temp file; PROC EXPORT DATA=BASEBALL86 OUTFILE = '/home/u59281773/sasuser.v94/Baseball86.xlsx' DBMS = xlsx REPLACE; RUN; ODS CSV FILE=‘/home/u59281773/sasuser.v94/BALL1986.csv’; PROC PRINT DATA=BASEBALL86; RUN; ODS CSV CLOSE;
In the future, please include the errors that you're receiving or indicate what is happening. We cannot run your code as we don't have the source files.
For your first issue, I think you have pretty quotes around your path, it needs to be a single or double quote not the curly ones. Office applications have a tendency to add those - did you copy/paste your code from somewhere. Basically, replace your quotes around the path for the CSV file and I think it'll be fine.
Notice how the editor doesn't color it the same way it colours other quoted text, highlighting that it's different.
Regarding filtering out observations - there is no NOMISS option on SGPLOT perhaps that is in another procs you've seen? You can filter out data using a WHERE statement but it depends exactly on what you're trying to filter out. Typically missing data is filtered out by default.
@akimme wrote:
Hello, I'm new and I keep getting errors when I try to create a CSV:
ODS CSV FILE=‘/home/u59281773/sasuser.v94/BALL1986.csv’; PROC PRINT DATA=BASEBALL86; RUN; ODS CSV CLOSE;
or exclude missings from a boxplot:
PROC SGPLOT DATA = BIRTH2001 nomiss; VBOX tounces / GROUP = SMOKE; TITLE 'Birthweights by Smoking Status'; RUN;
Putting NOMISS in the initial PROC SGPLOT is how I think I've seen others do it, but all it does is cause a syntax error and make my graph disappear!
Can anyone advise? Thanks!
Full code:
Spoiler%web_drop_table(BIRTH); FILENAME REFFILE '/home/u59281773/sasuser.v94/LIB/nc_birth.xlsx'; PROC FORMAT; VALUE RACE /*labels the possible values of the variables*/ 0='other non-White' 1='White' 2='Black' 3='American Indian' 4='Chinese' 5='Japanese' 6='Hawaiian' 7='Filipino' 8='Other Asian or Pacific Islander'; VALUE SMOKESTAT 0 = 'No' 1 = 'Yes' ; RUN; PROC IMPORT DATAFILE=REFFILE DBMS=XLSX OUT=BIRTH; GETNAMES=YES; SHEET='Sheet1'; /*selecting which sheet within the file to use*/ RUN; PROC CONTENTS DATA=BIRTH; RUN; %web_open_table(BIRTH); data BIRTH2001; set BIRTH; LABEL RACEMOM = 'Race of Mother' SMOKE = 'Did mother smoke during pregnancy?'; /*attempt to label the variables*/ FORMAT RACEMOM RACE. SMOKE SMOKESTAT.; run; *Creating the histograms; PROC SGPLOT DATA = BIRTH2001; HISTOGRAM tgrams; TITLE 'Birthweights in Ounces'; RUN; PROC SGPLOT DATA = BIRTH2001; HISTOGRAM tounces; TITLE 'Birthweights in Grams'; RUN; PROC SGPLOT DATA = BIRTH2001 nomiss; VBOX tounces / GROUP = SMOKE; TITLE 'Birthweights by Smoking Status'; RUN; *how to exclude missings?; PROC SGPLOT DATA = BIRTH2001; REG x=gained y=tgrams; TITLE 'Birthweights by Weight Gain During Pregnancy'; RUN; DATA BASEBALL86; SET sashelp.BASEBALL; TITLE 'Baseball 86 Stats'; RUN; *create temporary dataset with preset data; *Creating Excel file and replacing previous temp file; PROC EXPORT DATA=BASEBALL86 OUTFILE = '/home/u59281773/sasuser.v94/Baseball86.xlsx' DBMS = xlsx REPLACE; RUN; ODS CSV FILE=‘/home/u59281773/sasuser.v94/BALL1986.csv’; PROC PRINT DATA=BASEBALL86; RUN; ODS CSV CLOSE;
I didn't realize copying and pasting from Word used different quotes! That fixed that part, thank you. Is there any other character that I can't write out in Word and copy?
And the WHERE statements worked!
As @Reeza says, pretty quotes.
If you look closely at these two lines it is easy to see the first line uses vertical quote mark and the second curly quotes. The curly ones are not valid syntax.
OUTFILE = '/home/u59281773/sasuser.v94/Baseball86.xlsx' ODS CSV FILE=‘/home/u59281773/sasuser.v94/BALL1986.csv’;
What makes you think that missing values are included in a boxplot? Missing for which variable?
Yep, I had the wrong quotes in there - thanks!
My boxplots had a third, gray box for missings. I switched NOMISS for WHERE and I think it's good to go now
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.