Learning SAS? Welcome to the exclusive online community for all SAS learners.

How to get a variable creation program to work in UNI

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

How to get a variable creation program to work in UNI

So I wanted to avoid double posting so I closed out a previous post so there could just be a focused question. The variable creation program appears to be functional except it won't link to the dataset in University. It seems the directory naming for the dataset is the likely issue.The code is below:

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 LIBNAME IN1 '/folders/myfolders';
NOTE: Libref IN1 refers to the same physical library as OUT1.
NOTE: Libref IN1 was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders
63 LIBNAME OUT1 '/folders/myfolders/';
NOTE: Libref OUT1 refers to the same physical library as IN1.
NOTE: Libref OUT1 was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders
64 LIBNAME LIBRARY '/folders/myfolders/FMTLIB/';
NOTE: Library LIBRARY does not exist.
64 !
65
66 TITLE1 'CREATION AND VALIDATION OF COMORBIDITY MEASURES FOR';
67 TITLE2 'USE WITH DISCHARGE ADMINISTRATIVE DATA';
68
69 /*******************************************************************/
70 /* Macro Variables that must be set to define the characteristics */
71 /* of the input discharge data to the program */
72 /*******************************************************************/
73 * Maximum number of DXs; %LET NUMDX = 15;
74 * Input SAS file member name; %LET CORE = XXXXXX;
75
76
77 DATA OUT1.ANALYSIS;
78
79 SET IN1.&CORE (KEEP=DRG DX1-DX&NUMDX NDX);
ERROR: File IN1.XXXXXX.DATA does not exist.
80
81 DROP DRG DX1-DX&NUMDX NDX I J DXVALUE A1-A30
82 HTN HTNCX
83 CARDFLG PERIFLG CEREFLG PULMFLG DIABFLG
84 HYPOFLG RENALFLG RENFFLG LIVERFLG
85 ULCEFLG HIVFLG LEUKFLG CANCFLG ARTHFLG
86 NUTRFLG ANEMFLG ALCFLG NERVFLG HTNCXFLG HTNFLG
87 PSYFLG OBESEFLG DEPRSFLG COAGFLG
88 HTNPREG_ HTNWOCHF_ HTNWCHF_ HRENWORF_
89 HRENWRF_ HHRWOHRF_ HHRWCHF_ HHRWRF_
90 HHRWHRF_ OHTNPREG_ ;
 
 
So my first concern is that it says the library (which I did create) does not exist.
 
The second is how to get it to apply itself to the dataset. It says that IN1.XXXXX does not exist. Now I did try changing that XXXXX to sample.sas (under %LET CORE = XXXXXX).  Again I assume its a simple formatting issue, Any further help would be appreciated. 
 
Thanks again.

Accepted Solutions
Solution
‎12-30-2016 01:54 PM
Super User
Posts: 10,500

Re: How to get a variable creation program to work in UNI

If a data set is a SAS data set you should not include the file extension, only the library and data set:  library.datasetname

 

So use: %let Core=sample.

 

Then the statement IN1.&core resolves to In1.sample which is the way to reference sas data sets.

 

The syntax is intentionally set up this way as SAS runs across multiple operating systems and can reference older versions of data sets with different extensions when the libname is specified to do so. Note this also parallels many DBMS which will use DatabaseName.TableName syntax.

View solution in original post


All Replies
Super User
Posts: 6,936

Re: How to get a variable creation program to work in UNI

If SAS tells you that a certain path does not exist, then it doesn't exist. Period.

Keep in mind that the UNIX VM of SAS UE is case sensitive, so FMTLIB <> Fmtlib <> fmtlib.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 10,500

Re: How to get a variable creation program to work in UNI

For this:

64 LIBNAME LIBRARY '/folders/myfolders/FMTLIB/';
NOTE: Library LIBRARY does not exist.
Does the folder folders/myfolders/FMTLIB exist? Is it FMTLIB or fmtlib? the name of folders is case sensitive.
And you don't want the final / in the name.
 
Using multiple references to the same physical location as in your Libraries In1 and Out1 is not best practice in SAS. Know which library you want and use that.
 
Did you have a program working before using any macro variables? That is usually the way to start and then replace elements.
If SAS says the data set doesn't exist you do not have a data set.
Your reference "changing that XXXXX to sample.sas " means that you may have a fundamental misunderstanding of the difference between a data set and a program file (sample.sas). I would expect a file named SAMPLE.SAS to be program code file. Which is not going to be valid for a SET statement as SET requires either a data set or data view as the first parameter.
Occasional Contributor
Posts: 8

Re: How to get a variable creation program to work in UNI

So, the library not found issue was just a careless typo (I missed a folder subdirectory in transposing the program).

I have limited SAS experience, but this program (supposedly) is well tested so I assume it should be functional.  The issue I am having is what I am supposed to be placing under LETCORE=   (I assume the XXXXX is just a placeholder written by the creators meant to be substituted with your data, i.e., sample.sas7bdat).I plugged in the what I beleive to be the proper syntax and now get different errors. I apologize for my limited understanding, I honestly had (wrongfully) assumed that given a prewritten program this would be slightly easier to grasp, but even watching tutorials has not helped as much as members of this board, so thanks again. As to the library issue (using the same for in and out) there is only one dataset, along with one library that I created, so what would the alternative "Out library" even be?  I suppose this type of lack of understanding is at least part of my issue.

Below is the new message I get:

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 LIBNAME IN1 '/folders/myfolders';
NOTE: Libref IN1 refers to the same physical library as OUT1.
NOTE: Libref IN1 was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders
63 LIBNAME OUT1 '/folders/myfolders/';
NOTE: Libref OUT1 refers to the same physical library as IN1.
NOTE: Libref OUT1 was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders
64 LIBNAME LIBRARY '/folders/myfolders/COMORB/FMTLIB/';
NOTE: Libref LIBRARY was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/COMORB/FMTLIB
64 !
65
66 TITLE1 'CREATION AND VALIDATION OF COMORBIDITY MEASURES FOR';
67 TITLE2 'USE WITH DISCHARGE ADMINISTRATIVE DATA';
68
69 /*******************************************************************/
70 /* Macro Variables that must be set to define the characteristics */
71 /* of the input discharge data to the program */
72 /*******************************************************************/
73 * Maximum number of DXs; %LET NUMDX = 15;
74 * Input SAS file member name; %LET CORE = /folders/myfolders/sample.sas7bdat/;
75
76
77 DATA OUT1.ANALYSIS;
78
79 SET IN1.&CORE (KEEP=DRG DX1-DX&NUMDX NDX);
NOTE: Line generated by the macro variable "CORE".
79 IN1./folders/myfolders/sample.sas7bdat/
_____
22 22
201 76
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, CUROBS, END, INDSNAME, KEY, KEYRESET, KEYS,
NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.
 
ERROR 201-322: The option is not recognized and will be ignored.
 
ERROR 76-322: Syntax error, statement will be ignored.
Solution
‎12-30-2016 01:54 PM
Super User
Posts: 10,500

Re: How to get a variable creation program to work in UNI

If a data set is a SAS data set you should not include the file extension, only the library and data set:  library.datasetname

 

So use: %let Core=sample.

 

Then the statement IN1.&core resolves to In1.sample which is the way to reference sas data sets.

 

The syntax is intentionally set up this way as SAS runs across multiple operating systems and can reference older versions of data sets with different extensions when the libname is specified to do so. Note this also parallels many DBMS which will use DatabaseName.TableName syntax.

Occasional Contributor
Posts: 8

Re: How to get a variable creation program to work in UNI

Worked like a charm. Thank you.

☑ This topic is SOLVED.

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

Discussion stats
  • 5 replies
  • 357 views
  • 1 like
  • 3 in conversation