BookmarkSubscribeRSS Feed
haotiansas
Calcite | Level 5

Hi all-

I am encountering some issues with the Proc Compare procedure using SAS Studio.

I’ve tried to lay out the two main challenges I’m facing with the Compare procedure and maybe you could provide some guidance.

  1.   Date format – I’d like the output to show the actual date “06/23/2015” instead of “42178”.
  2.   Y-axis format – I’d like the output under Obs to say “Test 6” instead of “6”

SAS Output.jpg

SAS Original Excel.jpg

Here's my code:


proc import datafile='/folders/myfolders/iPlan/ExcelCompareWorksheets.xlsx'

                out=work.myexcel

                dbms=xlsx;

                range='NewGoat$C2:CJ89';

run;

proc import datafile='/folders/myfolders/iPlan/ExcelCompareWorksheets.xlsx'

                out=work.myexcel2

                dbms=xlsx;

                range='OldGoat$C2:CJ89';

run;

proc compare base=myexcel compare=myexcel2;

run;

Thanks in advance for reading and offering any guidance!

3 REPLIES 3
ballardw
Super User

Priory to the proc compare you would need to assign a format to display the values as needed. For your dates a format of mmddyy10. would work.

proc datasets library=work nodetails memtype=data;  /* assumes the two sets are in the library work*/

modify myexcel; format <names of your date variables> mmddyy10. ;

modify myexcel2; format <names of your date variables> mmddyy10. ;

quit;

I'm not sure there is a good easy way to replicate the proc compare output and change the OBS to read Test xxx.

haotiansas
Calcite | Level 5

Hello, thanks for the tip! I used your code and ran into the following errors;

NOTE: Statements not processed because of errors noted above.

57 ! format <Finish> mmddyy10. ;

  _

  22

  76

ERROR 22-322: Syntax error, expecting one of the following: a name, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. 

ERROR 76-322: Syntax error, statement will be ignored.

58 modify myexcel2;

58 ! format <Start> mmddyy10. ;

  _

  22

  76

ERROR 22-322: Syntax error, expecting one of the following: a name, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. 

ERROR 76-322: Syntax error, statement will be ignored.

59 quit;

NOTE: Statements not processed because of errors noted above.

NOTE: The SAS System stopped processing this step because of errors.

My code:

proc import datafile='/folders/myfolders/iPlan/ExcelCompareWorksheets.xlsx'

                out=work.myexcel

                dbms=xlsx;

                range='NewGoat$B2:BJ89';

run;

proc import datafile='/folders/myfolders/iPlan/ExcelCompareWorksheets.xlsx'

                out=work.myexcel2

                dbms=xlsx;

                range='OldGoat$B2:BJ89';

run;

proc datasets library=work nodetails memtype=data;  /* assumes the two sets are in the library work*/

modify myexcel; format <Finish> mmddyy10. ;

modify myexcel2; format <Start> mmddyy10. ;

quit;

proc compare base=myexcel compare=myexcel2;

run;

ballardw
Super User

Don't put the variable names within <> I put those there to indicate that you put a list of variables and I did not know all of the variables that you want to set the format for. This uses the same syntax as the FORMAT statement in a data step:

Format <list of variable names> <format for those variables> <another list of variables> <format for other variables> ;

Such as:

Format thisdate thatdate mmddyy10. thisnum thatnum theothernum F7.2 ;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1059 views
  • 1 like
  • 2 in conversation