BookmarkSubscribeRSS Feed
ksriram225
Calcite | Level 5
 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 ***********************************************************;
74 * Activity 6.02 *;
75 * 1) Complete the PROC EXPORT step to read the *;
76 * PG1.STORM_FINAL SAS table and create a *;
77 * comma-delimited file named STORM_FINAL.CSV. Use *;
78 * &outpath to substitute the path of the output *;
79 * folder. *;
80 * 2) Run the program and view the text file: *;
81 * *;
82 * SAS Studio - Navigate to the output folder in the *;
83 * Navigation pane, right-click on storm_final.csv, *;
84 * and select View File as Text. *;
85 * *;
86 * Enterprise Guide - Select Open -> Other and *;
87 * navigate to the output folder. Select *;
88 * storm_final.csv and click Open. Click Cancel in *;
89 * the Import Data window. *;
90 ***********************************************************;
91 * Syntax *;
92 * *;
93 * PROC EXPORT DATA=input-table *;
94 * OUTFILE="output-file" *;
95 * <DBMS=identifier> <REPLACE>; *;
96 * RUN; *;
97 ***********************************************************;
98 %let outpath = "/folders/myfolders/EPG194/output";
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
NOTE: The SAS System stopped processing this step because of errors.
99 proc export data = pg1.storm_final outfile = "/&outpath/storm_final.csv" dbms=csv replace;
NOTE: Line generated by the macro variable "OUTPATH".
99 "/"/folders/myfolders/EPG194/output"
_
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, DATA, DBLABEL, DBMS, DEBUG, FILE, LABEL, OUTFILE, OUTTABLE, REPLACE,
TABLE, _DEBUG_.
 
ERROR 76-322: Syntax error, statement will be ignored.
 
100 run;
101
102
103 OPTIONS NOTES NOSTIMER NO SOURCE NOSYNTAXCHECK;
115

I am unable to find the error even though the syntax is correct. Please help me with this one.

11 REPLIES 11
PaigeMiller
Diamond | Level 26
98 %let outpath = "/folders/myfolders/EPG194/output";

Macro variables generally should not have quotes around their values, and in this particular case, is the cause of your error. Remove the quotes.

--
Paige Miller
Kurt_Bremser
Super User

When defining a macro variable, everything up to the first (unmasked) semicolon (excluding leading and trailing blanks) becomes part of the content of the macro variable. This includes any quotes. So your OUTFILE option becomes this after the macro variable is resolved:

outfile = "/"/folders/myfolders/EPG194/output"/storm_final.csv"

which can't be interpreted as valid code. Work out for yourself how you have to change the macro variable to create valid code.

vishnukumaroff
Fluorite | Level 6
problem has not solved
vishnukumaroff
Fluorite | Level 6

in coursera answer is 3092 worked and got it. use the file path correctly u will get it

YashaswiniBS
Calcite | Level 5

Hi Vishnu,

It will be of great help if you can please provide the code. Your answer is right.

Cynthia_sas
SAS Super FREQ

Hi:
  The path that starts /folders/myfolders is an older path so you are looking at code that is an example of solving this problem on our old SAS University Edition product, which has now been retired.
  If you are using SAS OnDemand for Academics, then the path to your output folder should be something like
%let outpath=/home/userID/EPG1V2/output;


So if your userID was u1234567, then your path location for the output file would be something like:
%let outpath=/home/u1234567/EPG1V2/output;


To find the correct path, as explained many times before Lesson 6, open the Server Files and Folders panel and right click on the output subfolder under the EPG1V2 class folder. In the popup window when you right click, choose Properties and the path that you see in the Properties window for the output folder is the path you should use WITHOUT quotes (as already noted) in the %LET statement to make the &outpath helper macro variable.
Cynthia

YashaswiniBS
Calcite | Level 5
Thanks for your time Ms.Cynthia
YashaswiniBS
Calcite | Level 5
No errors found.
But not getting the solution, please have a look at the code.
kindly guide
YashaswiniBS
Calcite | Level 5
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 %let outpath=/home/u44636833/EPG1V2/output;
70
71 proc export data=np.storm_final outfile="&outpath.csv" dbms=csv
72 replace;
73 run;

NOTE: Unable to open parameter catalog: SASUSER.PARMS.PARMS.SLIST in update mode. Temporary parameter values will be saved to
WORK.PARMS.PARMS.SLIST.
74 /**********************************************************************
75 * PRODUCT: SAS
76 * VERSION: 9.4
77 * CREATOR: External File Interface
78 * DATE: 10SEP23
79 * DESC: Generated SAS Datastep Code
80 * TEMPLATE SOURCE: (None Specified.)
81 ***********************************************************************/
82 data _null_;
83 %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
84 %let _EFIREC_ = 0; /* clear export record count macro variable */
85 file '/home/u44636833/EPG1V2/outputcsv' delimiter=',' DSD DROPOVER lrecl=32767;
86 if _n_ = 1 then /* write column names or labels */
87 do;
88 put
89 "Season"
90 ','
91 "Name"
92 ','
93 "Basin"
94 ','
95 "BasinName"
96 ','
97 "OceanCode"
98 ','
99 "Ocean"
100 ','
101 "StormType"
102 ','
103 "MaxWindMPH"
104 ','
105 "MaxWindKM"
106 ','
107 "MinPressure"
108 ','
109 "StartDate"
110 ','
111 "EndDate"
112 ','
113 "StormLength"
114 ','
115 "Lat"
116 ','
117 "Lon"
118 ;
119 end;
120 set NP.STORM_FINAL end=EFIEOD;
121 format Season best4. ;
122 format Name $char57. ;
123 format Basin $char2. ;
124 format BasinName $14. ;
125 format OceanCode $2. ;
126 format Ocean $8. ;
127 format StormType $13. ;
128 format MaxWindMPH best12. ;
129 format MaxWindKM 3. ;
130 format MinPressure best12. ;
131 format StartDate date9. ;
132 format EndDate date9. ;
133 format StormLength best12. ;
134 format Lat best12. ;
135 format Lon best12. ;
136 do;
137 EFIOUT + 1;
138 put Season @;
139 put Name $ @;
140 put Basin $ @;
141 put BasinName $ @;
142 put OceanCode $ @;
143 put Ocean $ @;
144 put StormType $ @;
145 put MaxWindMPH @;
146 put MaxWindKM @;
147 put MinPressure @;
148 put StartDate @;
149 put EndDate @;
150 put StormLength @;
151 put Lat @;
152 put Lon ;
153 ;
154 end;
155 if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */
156 if EFIEOD then call symputx('_EFIREC_',EFIOUT);
157 run;

NOTE: The file '/home/u44636833/EPG1V2/outputcsv' is:
Filename=/home/u44636833/EPG1V2/outputcsv,
Owner Name=u44636833,Group Name=oda,
Access Permission=-rw-r--r--,
Last Modified=10Sep2023:11:43:26

NOTE: 31 records were written to the file '/home/u44636833/EPG1V2/outputcsv'.
The minimum record length was 76.
The maximum record length was 124.
NOTE: There were 30 observations read from the data set NP.STORM_FINAL.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 10839.37k
OS Memory 28960.00k
Timestamp 09/10/2023 06:13:26 AM
Step Count 18 Switch Count 0
Page Faults 0
Page Reclaims 220
Page Swaps 0
Voluntary Context Switches 6
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 16


30 records created in /home/u44636833/EPG1V2/outputcsv from NP.STORM_FINAL.


NOTE: "/home/u44636833/EPG1V2/outputcsv" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.04 seconds
user cpu time 0.03 seconds
system cpu time 0.02 seconds
memory 10839.37k
OS Memory 29220.00k
Timestamp 09/10/2023 06:13:26 AM
Step Count 18 Switch Count 8
Page Faults 0
Page Reclaims 3876
Page Swaps 0
Voluntary Context Switches 86
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 112


158
159
160 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
170
Kurt_Bremser
Super User

A dot terminates a macro variable reference. It vanishes when the macro variable is resolved.

If you need the contents of a macro variable followed by a dot in a string, you must use two dots: one to terminate the macro variable reference, the other to end up in the string.

 

I also suspect that your macro variable &outpath contains the path to a directory, so you must add a file name:

proc export
  data=np.storm_final
  outfile="&outpath./storm_final.csv"
  dbms=csv
  replace
;
YashaswiniBS
Calcite | Level 5
Thank you Sir.
I will follow your instructions.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 11 replies
  • 2786 views
  • 6 likes
  • 6 in conversation