DATA Step, Macro, Functions and more

sas macro proc import

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

sas macro proc import

hi there,

i am using the following code to dynamically import the data:

it is working all right if my "tbl_in" is same as its defined i.e. upper case, but its not working it is in lower case i.e. "ver_voal_std.csv"

%let tbl_in = VER_VOAL_STD.csv;

PROC IMPORT datafile = "&FromLoc.&tbl_in."

                  OUT= %sysfunc(compress(&Prefix. &OutName.))

            DBMS=csv REPLACE;

                  getnames=yes;
RUN;

anybody can help me how can i fix that?

Thanks,

KP


Accepted Solutions
Solution
‎02-23-2015 07:13 AM
Super Contributor
Posts: 282

Re: sas macro proc import

Posted in reply to KrunalPatel

Hi,

You could try using the %upcase function when referencing the macro variable. E.g.:

PROC IMPORT datafile = "&FromLoc.%upcase(&tbl_in.)"

The periods (.) should also no longer be necessary.

Regards,

Amir.

View solution in original post


All Replies
Solution
‎02-23-2015 07:13 AM
Super Contributor
Posts: 282

Re: sas macro proc import

Posted in reply to KrunalPatel

Hi,

You could try using the %upcase function when referencing the macro variable. E.g.:

PROC IMPORT datafile = "&FromLoc.%upcase(&tbl_in.)"

The periods (.) should also no longer be necessary.

Regards,

Amir.

Super Contributor
Posts: 282

Re: sas macro proc import

Posted in reply to KrunalPatel

Hi,

I just realised the ".csv" extension was lowercase, so perhaps that would have to be separate to the rest of the file name in another macro variable.

See what your testing reveals.

Regards,

Amir.

Contributor
Posts: 21

Re: sas macro proc import

Hi Amir,

thanks a lot.

Its working using %upcase();

Thanks,

KP


Super User
Posts: 7,868

Re: sas macro proc import

Posted in reply to KrunalPatel

If your SAS process runs on a UNIX platform, filenames (as everything else in UNIX) are case sensitive.

"VER_VOAL_STD.csv", "ver_voal_std.csv", "VER_VOAL_STD.CSV" and "ver_voal_std.CSV" are all different objects and can exist side by side. (Also "Ver_voal_std.csv", you get the idea)

Define a standard way to write filenames (all lower case preferred) to make life easier, but also make sure that the case-sensitiveness is kept throughout the process. Make no assumptions, but use names "as is".

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 295 views
  • 3 likes
  • 3 in conversation