BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GenDemo
Quartz | Level 8

Hi All

 

I have been coding in base SAS (henceforth just SAS for simplicity) for a number of year now, and only now trying out EG (v6.1) as I need to schedule jobs to run automatically. Hence I've been coding in base SAS, then putting that program in a EG project and scheduling it. Through this process I noticed that SAS & EG treat their error slightly differently, and I've just encountered a problem with variable names and label that is completely different.

Also, if there are other hints or inputs anyone can provide relating to the idea that I code in SAS and then just feed the program into a EG project, I would appreciate it.

 

Its a simple excersice, but the way it handles the variable names & lables seem to be different, and I would really appreciate some insight into this.

 

The Data that I am suing is as follows. I want a table with indicator/dummy variables to show what applications has each of the borrower types.

Application_ID BorrowerType
74739 Primary
202258 Primary
210707 Primary
211814 Guarantor 1
211814 Guarantor 2
211814 Primary
220859 Guarantor 1
224290 Guarantor 1
224290 Guarantor 2
224790 Primary
225202 Primary
253492 Guarantor 1
253492 Primary
287221 Co-Borrower
287221 Primary

 

Hence I run

 

proc freq data=BorrowerTypes noprint;

tables Application_ID*BorrowerType / missing out=BorrowerTypes_freq (drop=PERCENT);

run;

 

 

 

Application_ID BorrowerType Frequency
Count
747397 Primary 1
2022858 Primary 1
2109707 Primary 1
2118144 Guarantor 1 1
2118144 Guarantor 2 1
2118144 Primary 1
2208559 Guarantor 1 1
2208559 Primary 1
2247290 Guarantor 1 1
2247290 Guarantor 2 1
2247290 Primary 1
2252021 Primary 1
2253492 Guarantor 1 1
2253492 Primary 1
2287221 Co-Borrower 1
2287221 Primary 1

 

 

Then I run a transpose:

 

proc transpose data=BorrowerTypes_freq out=BorrowerTypes_freq_t (drop= _LABEL_ _NAME_);

by Application_ID;

var count;

ID BorrowerType;

run;

 

 

 

Application_ID Primary Guarantor_1 Guarantor_2 Co_Borrower
747397 1 . . .
2022858 1 . . .
2109707 1 . . .
2118144 1 1 1 .
2208559 1 1 . .
2247290 1 1 1 .
2252021 1 . . .
2253492 1 1 . .
2287221 1 . . 1

 

 

everything up to here runs the same in SAS & EG. Then in the next step is where the difference comes in:

 

data BorrowerTypes_freq_t;

set BorrowerTypes_freq_t;

Guarantor = (Guarantor_1 = 1 | Guarantor_2 = 1);

Secondary = (Guarantor = 1 | Co_Borrower = 1);

run;

 

 

 

The results in SAS look like this:

Application_ID Primary Guarantor_1 Guarantor_2 Co_Borrower Guarantor Secondary
747397 1 . . . 0 0
2022858 1 . . . 0 0
2109707 1 . . . 0 0
2118144 1 1 1 . 1 1
2208559 1 1 . . 1 1
2247290 1 1 1 . 1 1
2252021 1 . . . 0 0
2253492 1 1 . . 1 1
2287221 1 . . 1 0 1

 

while in EG they look like this:

Application_ID Primary Guarantor 1 Guarantor 2 Co-Borrower Guarantor Secondary Guarantor_1 Guarantor_2 Co_Borrower
747397 1 . . . . . . . .
2022858 1 . . . . . . . .
2109707 1 . . . . . . . .
2118144 1 1 1 . . . . . .
2208559 1 1 . . . . . . .
2247290 1 1 1 . . . . . .
2252021 1 . . . . . . . .
2253492 1 1 . . . . . . .
2287221 1 . . 1 . . . . .

 

I hope this makes sense...and i would appreciate any insight into it - SAS can't use the spaces in the variable names, and hence puts "_" in, however, it seems that EG can use this, and hence my base SAS code does not work.

 

 

Thnx in advance

 

GD

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Your SAS code as such gets executed by the SAS server and whether you access this server via EG or via "PC SAS" will make no difference.

 

What can be different are environment settings (eg. set by the object spawner) and - unfortunately - by EG adding some code at the beginning and end of your program before transmitting the code to the server (export your code from EG into a .sas file and you'll see what gets added).

 

One of the things added by default is options validvarname=any; You can change at least this one in the EG options settings by choosing "use setting from server".

Capture.PNG

View solution in original post

5 REPLIES 5
Jagadishkatam
Amethyst | Level 16
To overcome this issue in SAS EG and make your code work in SAS EG similar to in BASE SAS, please execute the program by placing the option statement.

option validvarname=v7;

followed by your code.
Thanks,
Jag
Jagadishkatam
Amethyst | Level 16

Alternatively if you want to run the below code in SAS EG then by using the name literals concept we could make it work as updated in the code

 

data BorrowerTypes_freq_t;
set BorrowerTypes_freq_t;
Guarantor = (Guarantor_1 = 1 | Guarantor_2 = 1);
Secondary = (Guarantor = 1 | Co_Borrower = 1);
run;

/*change to the below code in SAS EG. This is an approach of name literals*/

data BorrowerTypes_freq_t;
set BorrowerTypes_freq_t;
Guarantor = ('Guarantor 1'n = 1 | 'Guarantor 2'n = 1);
Secondary = (Guarantor = 1 | Co_Borrower = 1);
run;
Thanks,
Jag
Ksharp
Super User
Becasue EG use 
options validvarname=any;

while your base sas use:
options validvarname=v7;

Patrick
Opal | Level 21

Your SAS code as such gets executed by the SAS server and whether you access this server via EG or via "PC SAS" will make no difference.

 

What can be different are environment settings (eg. set by the object spawner) and - unfortunately - by EG adding some code at the beginning and end of your program before transmitting the code to the server (export your code from EG into a .sas file and you'll see what gets added).

 

One of the things added by default is options validvarname=any; You can change at least this one in the EG options settings by choosing "use setting from server".

Capture.PNG

GenDemo
Quartz | Level 8

Awesome, that solved my problem! Thnx guys!  😄

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 5 replies
  • 1076 views
  • 1 like
  • 4 in conversation