sas

How to use select statement in a value statement

房东的猫 提交于 2019-12-25 02:57:31
问题 I'm not sure what's wrong with my code. The log is saying that the select has a syntax error which I copied below. How do I fix this? "Syntax error, expecting one of the following: a quoted string, a numeric constant,a datetime constant, a missing value, +, -, MISSING, NULL, USER. ERROR: Syntax error, statement will be ignored." proc sql; insert into orion.test (Fruits, Vegetables, Drinks, Meats) values (select a.fruit, a.veggie, a.drink, a.meat FROM work.meals AS a); quit; 回答1: This should

How to create a macro variable within a macro?

廉价感情. 提交于 2019-12-25 02:46:29
问题 I am wondering how to create a SAS macro variable within a block of SAS %MACRO statement? It appears that my CALL SYMPUT or my SELECT INTO statements aren't working when they are in a block of %MACRO statement. %MACRO NONDATE_FORMAT_CHECK(varname=,output=); PROC SQL; CONNECT TO NETEZZA AS NET (SERVER=&server DATABASE=&database USER=&NBKID PASSWORD=&NBKPASSWD); CREATE TABLE WORK.DT_FMT&output AS SELECT * FROM CONNECTION TO NET (SELECT 'FORMAT_IS_DATE' AS DT_FMT_INDICATOR FROM &input_database

SAS set a variable from a filename

你离开我真会死。 提交于 2019-12-25 02:41:01
问题 I have a number of csv files in a folder. They all have the same structure (3 columns). The SAS code below imports all of them into one dataset. It includes the 3 columns plus their file name. My challenge is that the filename variable includes the directories and drive letter (e.g. 'Z:\DIRECTORYA\DIRECTORYB\file1.csv'). How can I just list the file name and not the path (e.g. file1.csv)? Thank you data WORK.mydata; %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ length FNAME

Invoke a Macro Using A Macro Variable Name

冷暖自知 提交于 2019-12-25 02:16:05
问题 Is it possible in SAS to invoke a call to a macro using a macro variable whose value is the macro's name? Something like the following: %MACRO TEST (macroName, var1, var2, var3, var4, var5); %put LOG: %&macroName(&var1); %MEND; %TEST(testName,testVar1); In response to Richard's answer. I tried following your solution, but am still getting an "apparent invocation of macro YearMonthString not resolved" using the following code: %MACRO YearMonthString(nYear,nMonth); /* Builds a string in the

How to escape the ' character in sas

六月ゝ 毕业季﹏ 提交于 2019-12-25 01:51:08
问题 I want to create a new variable as EVENT with the condition that :IF WORK='Active' AND CONDITION = 'planned convenience removal-no maint. req'd.' THEN EVENT='ISH '; But How to escape the ' character in sas. SL WORK CONDITION 1 Node part replaced or repaired 2 Active planned (convenience) removal-maint. req'd. 3 Active planned convenience removal-no maint. req'd. 4 Active prop strike 5 Node planned convenience removal-no maint. req'd. I tried percent symbol and tried ' ' double quote, its not

How do I encode Unicode strings using pyodbc to save to a SAS dataset?

我与影子孤独终老i 提交于 2019-12-25 01:42:44
问题 I'm using Python to read and write SAS datasets, using pyodbc and the SAS ODBC drivers. I can load the data perfectly well, but when I save the data, using something like: cursor.execute('insert into dataset.test VALUES (?)', u'testing') ... I get a pyodbc.Error: ('HY004', '[HY004] [Microsoft][ODBC Driver Manager] SQL data type out of range (0) (SQLBindParameter)') error. The problem seems to be the fact I'm passing a unicode string; what do I need to do to handle this? 回答1: Do you know what

Change from DDE to proc export because office 2016 does not support it

一曲冷凌霜 提交于 2019-12-25 00:59:15
问题 office excel 2016 for some reason does not support DDE command and therefore the following programs is crashing. Do you know how can I make it work? I have tried with proc export, I will add the code I tried as comment. Or if you have any other idea of how it can work, please share. Thank you in advance! ods listing close; ODS HTML path="path' (TITLE="CD"); title;footnote; %macro prnt; %if &nobs ne 0 %then %do; title1 "CDTC"; footnote "PROGRAM: (, UPDATED: &tist"; proc print data = dag.dc

Macro looping over columns in SAS broken by ods

∥☆過路亽.° 提交于 2019-12-24 22:17:09
问题 I just found that ods graphics / reset; broke my loop. I am still curious why this happened and if there are other potential similar pitfalls. Objective: I want to loop over columns in SAS and provide a plot where the x variable remains constant, but the y dimension varies. I could transpose and use a by statement. I don't want to do that. Problem: Despite the log with options mprint ; showing the text replacement is working properly, the outputted plots only display the final plot repeatedly

Retrieving tables located on metadata server with SAS

元气小坏坏 提交于 2019-12-24 20:05:02
问题 I want to list all tables on metadata server. I've tried with the following data step but it only pics one table per library and I can't figure out why. This is the code I've been using: options metaserver="xxxx" metaport=8561 metauser="xxxx" metapass="xxxx" METAPROTOCOL=BRIDGE metarepository="Foundation"; data meta_libraries; length uri serveruri conn_uri domainuri libname ServerContext AuthDomain path_schema usingpkguri type tableuri coluri $256 id $17 desc $200 libref engine $8 isDBMS $1

count the values in one column by SQL - using SAS

北慕城南 提交于 2019-12-24 18:51:44
问题 I have a customer_no and class . I would like to calculate ratio from the same column for each customer. ratio= (number of secured/ total number classes) customer_no class 1 unsecured 1 secured 1 secured 2 unsecured 2 secured 3 secured 3 unsecured 3 secured 3 unsecured The output sample will be customer_no ratio 1 0.666 2 0.50 3 0.50 . . . 20000 回答1: You can calculate ratio in a query like this: select customer_no, (count(case when class = 'secured' then 1 end) -- count if class is secured +0