I am trying to compare two tables using SAS code in PROC COMPARE.
The Table names are too long- they pass the 32 character limit.
I cannot re-name the files in the Source Database.
Is there anyway to get around this? I tried assigning to a variable, but that doesn't work.
you can create a view with a valid sas name (ie length name <= 32) and then use the view in proc compare.
Thankyou francesco. I started creating the views, but it was taking a long time as i had to create the source table as views as well. I decided to output the results to a text file and 'Compare' using Notepad ++. Great pluggin! :)) works wonders :)
Related
thanks for any help! I’ll try to be concise.
I am new to SAS and have inherited a SAS run that outputs a table with 15 columns, which I export as an excel file and deliver.
The recipient would now like it as a .txt file with fixed-width columns, and has provided the character limit/width for each column.
Is this something that can be done in query builder, so I can just query the existing table rather than modifying the code in the run? I tried filling the field for ‘Length’ when you add a column to query builder, but it did not have the desired result.
I have a dataset with 6 character variables including Day5,Day6,Day7,City1,City2,City3.
I am trying to rename Day5 which was extracted as i__Day5 after importing txt file into SAS. The variable i__day5 is not getting renamed to day5 and so it does not shows any observation for this variable.
data subset ;
set subset ;
rename i__Day5 = Day5;
run;
Thanks.
As Tom mentioned your problem likely stems from overwriting the original table with the modified data, and then trying to submit your code to run again.
It will work the first time when the variable i__Day5 exists, but on running it a second time, the variable will no longer exist as it has already been renamed.
To avoid this issue never re-use table names. This code would be better:
data subset2 ;
set subset ;
rename i__Day5 = Day5;
run;
Space is cheap so there's no real downside to doing this, plus it gives you an easy way to compare the table before/after running the code.
The only other issue that this could be is that you are viewing field labels and not field names. As samkart mentions, you can verify the actual field names by running a proc contents against your table.
I have a macro that I use to import Excel files from a Windows directory to SAS (version 9.3) on a Linux server. In general the macro has worked fine, but now I'm trying to import an Excel file with a column that contains mostly numeric data with some character records thrown in.
The variable looks something like this:
Var2
1111111
2222222
3333333
4444444
Multiple
5555555
H6666-01
The variable is getting read in as numeric so I'm losing the data in the fifth and seventh records. I've tried a few of the suggestions listed in this answer, but nothing seems to change the variable type.
Here's a portion of the macro I have:
proc import replace
out=&d_set
dbms=excelcs
file="\\path\to\file\&xlsx_nm";
sheet="&sheet_nm";
server="Server";
port=0000;
serveruser="&sysget_USER";
serverpassword="&pw";
range="&rng";
DBDSOPTS = "DBTYPE=(Var2='CHAR(8)')";
run;
I just added the statement DBDSOPTS = "DBTYPE=(Var2='CHAR(8)')"; based on the suggestion on the link above, but the output in the log did not change.
I have also tried padding the original Excel file with a "dummy" record (which I'd like to avoid) with character data in the column that I'm having issues with, but this also did not work.
I'd like to solve this in the import procedure but I'm open to other suggestions.
I have data inside SAS.
I want to store the datafile to SPSS format (*.sav)
I use the following program:
PROC export Data=SASdataToStoreInSPSS
FILE="Path\Filename_%sysfunc(today(),date9.).sav"
dbms=sav replace;
RUN;
This works great. Except when I open the file in SPSS the dates are strangly formatted.
For example:
156405 08:51:00
Should be
3-Jan-2011 08:51
I can manually change the data formats in SPSS. So the values are correct date values, except they are not automatically formatted in a readable format.
I tried to change the format in SAS before saving to DATETIME20. or DATETIME23.3. But this does not help.
I want this to work without having to open SPSS and run a Syntax there.
The SPSS files that SAS spits out have to be directly mailed to other users of the data.
I think this is either a bug with SAS's export, or an issue with SPSS where some default changed. What's happening is that SAS is storing it as a SPSS Date - but with width 16, which is not long enough to hold the complete datetime. I don't think you can use DBDSOPTS with DBMS=SPSS, so I don't know that there is a good workaround short of importing the file into SPSS.
You could do that automatically, though, using the SPSS Production facility; I've written an import script before and asked SAS to run spssprod with the batch file. That's an irritating workaround, but it might be the easiest, unless SAS Tech Support can help you (and certainly try that - they are usually only a few hours' turnaround for initial contact at least).
SAS mentioned it has to do with the SPSS driver they use. Apparently it is not an easy fix so they forwarded the issue to second-line tech support.
The workaround you will need is split the dates in two columns. One with date and one with time.
data SPSS2;
set SPSS;
date = put(datepart(DatumSPSS), date9.);
time = put(timepart(DatumSPSS), time8.);
run;
Or you can tell the end user how to change the format of the date in SPSS.
For an automated approach, try this .NET app. You need SPSS, but SAS is not required to convert a large collection of SAS files automatically.
Manual Process included code samples or Application Download
Could anybody tell me why does the compiler gives me an error - "ERROR: Insufficient page size to print frequency table." while running proc freq in sas.
I am trying to run a very simple peice of code.
proc freq data = seaepi;
tables trt* sex/ out = temp;
run;
I really appreciate your effort involved.
Thanks in advance.
> crossposted from SAS-L
I have had this problem before. This literally means that you have too many columns or you columns are too wide to fit on the page and so it will not print. Try to reduce the font size or reduce the number columns to see if you still have the problem.
Sometimes the way you handle a problem like this depends on your output destination. It would be helpful to know if you are using ODS PDF, or HTML or are just writing to the output window.
Run it with
option pagesize=max;
and see what that looks like. As mentioned already, the result will depend on what kind of output you are using. At least you can look at this output and see what it needs for a page.
If you have not tried, have a look at the options statement in SAS SAS Options Statement. There is a PageSize option which can be set.
In this case, since you've already requested that the frequency table is written to an output dataset, you could disable printing it in the results tab:
proc freq data = seaepi noprint;
tables trt* sex/ out = temp;
run;
If necessary, you could then export your output dataset or chop it into smaller bits for viewing via proc print.